"use strict";

const main = arg => {
    // 標準入力の不要な空白と改行を削除し、配列に格納する
    const input = arg.trim().split("\n");
    const numPeople = parseInt(input[0], 10);
    const xArray = input[1].split(" ").map(x => parseInt(x ,10));

    const sum  = function(arr) {
        return arr.reduce(function(prev, current, i, arr) {
            return prev+current;
        });
    };
    const average = function(arr, fn) {
        return sum(arr, fn)/arr.length;
    };
    
    const P = Math.floor(average(xArray));

    let answer = 0;
    xArray.forEach(x => {
        let HP = (x - P) * (x - P);
        //console.log(HP);
        answer += HP;
    });


    console.log(answer);
}

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