import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int num = sc.nextInt();
        int x[] = new int[num];
        int p = 0;
        for(int i = 0; i<num; i++){
            x[i] = sc.nextInt();
            p = p + x[i];
        }
        int ans1 = 0;
        int ans2 = 0;
        int ans = 0;
        p = p / num;
        
        for(int i = 0; i<num; i++){
            ans1 = ans1 + (x[i] - p) * (x[i] - p);
        }
        
        p++;
        
        for(int i = 0; i<num; i++){
            ans2 = ans2 + (x[i] - p) * (x[i] - p);
        }
        
        if(ans1 < ans2){
            ans = ans1;
        }else{
            ans = ans2;
        }
        
        System.out.println(ans);
    }
} import java.util.*; util.* java public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int num = sc.nextInt();
        int x[] = new int[num];
        int p = 0;
        for(int i = 0; i<num; i++){
            x[i] = sc.nextInt();
            p = p + x[i];
        }
        int ans1 = 0;
        int ans2 = 0;
        int ans = 0;
        p = p / num;
        
        for(int i = 0; i<num; i++){
            ans1 = ans1 + (x[i] - p) * (x[i] - p);
        }
        
        p++;
        
        for(int i = 0; i<num; i++){
            ans2 = ans2 + (x[i] - p) * (x[i] - p);
        }
        
        if(ans1 < ans2){
            ans = ans1;
        }else{
            ans = ans2;
        }
        
        System.out.println(ans);
    }
} Main public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int num = sc.nextInt();
        int x[] = new int[num];
        int p = 0;
        for(int i = 0; i<num; i++){
            x[i] = sc.nextInt();
            p = p + x[i];
        }
        int ans1 = 0;
        int ans2 = 0;
        int ans = 0;
        p = p / num;
        
        for(int i = 0; i<num; i++){
            ans1 = ans1 + (x[i] - p) * (x[i] - p);
        }
        
        p++;
        
        for(int i = 0; i<num; i++){
            ans2 = ans2 + (x[i] - p) * (x[i] - p);
        }
        
        if(ans1 < ans2){
            ans = ans1;
        }else{
            ans = ans2;
        }
        
        System.out.println(ans);
    } main {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int num = sc.nextInt();
        int x[] = new int[num];
        int p = 0;
        for(int i = 0; i<num; i++){
            x[i] = sc.nextInt();
            p = p + x[i];
        }
        int ans1 = 0;
        int ans2 = 0;
        int ans = 0;
        p = p / num;
        
        for(int i = 0; i<num; i++){
            ans1 = ans1 + (x[i] - p) * (x[i] - p);
        }
        
        p++;
        
        for(int i = 0; i<num; i++){
            ans2 = ans2 + (x[i] - p) * (x[i] - p);
        }
        
        if(ans1 < ans2){
            ans = ans1;
        }else{
            ans = ans2;
        }
        
        System.out.println(ans);
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int num = sc.nextInt(); num sc.nextInt() sc.nextInt sc int x[] = new int[num]; x new int[num] num int p = 0; p 0 for(int i = 0; i<num; i++){
            x[i] = sc.nextInt();
            p = p + x[i];
        } int i = 0; int i = 0; i 0 i<num i num i++ i++ i {
            x[i] = sc.nextInt();
            p = p + x[i];
        } {
            x[i] = sc.nextInt();
            p = p + x[i];
        } x[i] = sc.nextInt() x[i] x i sc.nextInt() sc.nextInt sc p = p + x[i] p p + x[i] p x[i] x i int ans1 = 0; ans1 0 int ans2 = 0; ans2 0 int ans = 0; ans 0 p = p / num p p / num p num for(int i = 0; i<num; i++){
            ans1 = ans1 + (x[i] - p) * (x[i] - p);
        } int i = 0; int i = 0; i 0 i<num i num i++ i++ i {
            ans1 = ans1 + (x[i] - p) * (x[i] - p);
        } {
            ans1 = ans1 + (x[i] - p) * (x[i] - p);
        } ans1 = ans1 + (x[i] - p) * (x[i] - p) ans1 ans1 + (x[i] - p) * (x[i] - p) ans1 (x[i] - p) * (x[i] - p) (x[i] - p) x[i] x i p (x[i] - p) x[i] x i p p++ p for(int i = 0; i<num; i++){
            ans2 = ans2 + (x[i] - p) * (x[i] - p);
        } int i = 0; int i = 0; i 0 i<num i num i++ i++ i {
            ans2 = ans2 + (x[i] - p) * (x[i] - p);
        } {
            ans2 = ans2 + (x[i] - p) * (x[i] - p);
        } ans2 = ans2 + (x[i] - p) * (x[i] - p) ans2 ans2 + (x[i] - p) * (x[i] - p) ans2 (x[i] - p) * (x[i] - p) (x[i] - p) x[i] x i p (x[i] - p) x[i] x i p if(ans1 < ans2){
            ans = ans1;
        }else{
            ans = ans2;
        } ans1 < ans2 ans1 ans2 {
            ans = ans1;
        } ans = ans1 ans ans1 {
            ans = ans2;
        } ans = ans2 ans ans2 System.out.println(ans) System.out.println System.out System System.out ans String[] args args public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int num = sc.nextInt();
        int x[] = new int[num];
        int p = 0;
        for(int i = 0; i<num; i++){
            x[i] = sc.nextInt();
            p = p + x[i];
        }
        int ans1 = 0;
        int ans2 = 0;
        int ans = 0;
        p = p / num;
        
        for(int i = 0; i<num; i++){
            ans1 = ans1 + (x[i] - p) * (x[i] - p);
        }
        
        p++;
        
        for(int i = 0; i<num; i++){
            ans2 = ans2 + (x[i] - p) * (x[i] - p);
        }
        
        if(ans1 < ans2){
            ans = ans1;
        }else{
            ans = ans2;
        }
        
        System.out.println(ans);
    }
} public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int num = sc.nextInt();
        int x[] = new int[num];
        int p = 0;
        for(int i = 0; i<num; i++){
            x[i] = sc.nextInt();
            p = p + x[i];
        }
        int ans1 = 0;
        int ans2 = 0;
        int ans = 0;
        p = p / num;
        
        for(int i = 0; i<num; i++){
            ans1 = ans1 + (x[i] - p) * (x[i] - p);
        }
        
        p++;
        
        for(int i = 0; i<num; i++){
            ans2 = ans2 + (x[i] - p) * (x[i] - p);
        }
        
        if(ans1 < ans2){
            ans = ans1;
        }else{
            ans = ans2;
        }
        
        System.out.println(ans);
    }
} Main
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int num = sc.nextInt();
        int x[] = new int[num];
        int p = 0;
        for(int i = 0; i<num; i++){
            x[i] = sc.nextInt();
            p = p + x[i];
        }
        int ans1 = 0;
        int ans2 = 0;
        int ans = 0;
        p = p / num;
        
        for(int i = 0; i<num; i++){
            ans1 = ans1 + (x[i] - p) * (x[i] - p);
        }
        
        p++;
        
        for(int i = 0; i<num; i++){
            ans2 = ans2 + (x[i] - p) * (x[i] - p);
        }
        
        if(ans1 < ans2){
            ans = ans1;
        }else{
            ans = ans2;
        }
        
        System.out.println(ans);
    }
}