(function Main(input){
	var input = input.split('\n'),
		X = input[1].split(' ').map(Number),
		len = X.length,
		result = 0,
		avg = function(data){
			var sum = 0;
			for(var i=0; i<len; i++){
				sum += data[i];
			}
			return Math.round(sum / len);
		}(X);
	for(var i=0; i<len; i++){
		result += Math.pow(X[i]-avg, 2);
	}
	console.log(result);
})(require("fs").readFileSync("/dev/stdin","utf8"));