'use strict';
function main(input) {
  const arr = input.trim().split('\n');
  const a = arr[1].split(' ').map(x => Number(x));
  let sum = 0;

  for (let i = 0; i < a.length; i ++) {
    sum += (arr[0] - a[i]) ** 2;
  }
  
  console.log(sum);
}

main(require("fs").readFileSync("/dev/stdin", "utf8"));