function Main(input) {
	input = input.split("\n");
	var N = input[0];
	var arr = input[1].split(" ").map(Number);
	var ans = Number.MAX_SAFE_INTEGER;
	var max = Math.max.apply(null,arr);
	
		for(var i=1;i<=max;i++){
			var sum = 0;
			for(var j=0;j<arr.length;j++){
				sum += Math.pow(Math.abs(arr[j]-i),2);
			}
         // console.log(i,sum)
			if(sum<ans) ans = sum;
		}
console.log(ans);

}Main(require("fs").readFileSync("/dev/stdin", "utf8").trim());