(function Main(input){
	var input  = input.split('\n'),
		X      = input[1].split(' ').map(Number),
		result = 0,
		avg    = function(data){
			var sum = 0,
				len = data.length;

			for(var i=0; i<len; i++){
				sum += data[i];
			}
			return Math.round(sum / len);
		}(X);
	
	for(var i=0; i<X.length; i++){
		result += Math.pow(X[i]-avg, 2);
	}
	console.log(result);
})(require("fs").readFileSync("/dev/stdin","utf8"));