import java.util.*;

class Main{
    public static void sort(int[] x){
      for(int i = 0; i < x.length; i++){
        for(int j = i+1; j < x.length; j++){
          if(x[i] > x[j]){
            int  t = x[i];
            x[i] = x[j];
            x[j] = t;
          }
        }
      }
    }
    public static void main(String[] args) {
        Scanner stdIn = new Scanner(System.in);
        int n = stdIn.nextInt();
        int x[] = new int[n];
        double ave = 0;
        for(int i = 0; i < n; i++){
          x[i] = stdIn.nextInt();
          ave += x[i];
        }
        int p = 0;
        ave = ave/(double)n;
        if(ave*10 % 10 >= 5) p = (int)(ave+1);
        else p = (int)ave;

        int ans = 0;
        for(int i = 0; i < n; i++)
          ans += (x[i] - p) * (x[i] - p);

        System.out.println(ans);
    }
} import java.util.*; util.* java class Main{
    public static void sort(int[] x){
      for(int i = 0; i < x.length; i++){
        for(int j = i+1; j < x.length; j++){
          if(x[i] > x[j]){
            int  t = x[i];
            x[i] = x[j];
            x[j] = t;
          }
        }
      }
    }
    public static void main(String[] args) {
        Scanner stdIn = new Scanner(System.in);
        int n = stdIn.nextInt();
        int x[] = new int[n];
        double ave = 0;
        for(int i = 0; i < n; i++){
          x[i] = stdIn.nextInt();
          ave += x[i];
        }
        int p = 0;
        ave = ave/(double)n;
        if(ave*10 % 10 >= 5) p = (int)(ave+1);
        else p = (int)ave;

        int ans = 0;
        for(int i = 0; i < n; i++)
          ans += (x[i] - p) * (x[i] - p);

        System.out.println(ans);
    }
} Main public static void sort(int[] x){
      for(int i = 0; i < x.length; i++){
        for(int j = i+1; j < x.length; j++){
          if(x[i] > x[j]){
            int  t = x[i];
            x[i] = x[j];
            x[j] = t;
          }
        }
      }
    } sort {
      for(int i = 0; i < x.length; i++){
        for(int j = i+1; j < x.length; j++){
          if(x[i] > x[j]){
            int  t = x[i];
            x[i] = x[j];
            x[j] = t;
          }
        }
      }
    } for(int i = 0; i < x.length; i++){
        for(int j = i+1; j < x.length; j++){
          if(x[i] > x[j]){
            int  t = x[i];
            x[i] = x[j];
            x[j] = t;
          }
        }
      } int i = 0; int i = 0; i 0 i < x.length i x.length x x.length i++ i++ i {
        for(int j = i+1; j < x.length; j++){
          if(x[i] > x[j]){
            int  t = x[i];
            x[i] = x[j];
            x[j] = t;
          }
        }
      } {
        for(int j = i+1; j < x.length; j++){
          if(x[i] > x[j]){
            int  t = x[i];
            x[i] = x[j];
            x[j] = t;
          }
        }
      } for(int j = i+1; j < x.length; j++){
          if(x[i] > x[j]){
            int  t = x[i];
            x[i] = x[j];
            x[j] = t;
          }
        } int j = i+1; int j = i+1; j i+1 i 1 j < x.length j x.length x x.length j++ j++ j {
          if(x[i] > x[j]){
            int  t = x[i];
            x[i] = x[j];
            x[j] = t;
          }
        } {
          if(x[i] > x[j]){
            int  t = x[i];
            x[i] = x[j];
            x[j] = t;
          }
        } if(x[i] > x[j]){
            int  t = x[i];
            x[i] = x[j];
            x[j] = t;
          } x[i] > x[j] x[i] x i x[j] x j {
            int  t = x[i];
            x[i] = x[j];
            x[j] = t;
          } int  t = x[i]; t x[i] x i x[i] = x[j] x[i] x i x[j] x j x[j] = t x[j] x j t int[] x x public static void main(String[] args) {
        Scanner stdIn = new Scanner(System.in);
        int n = stdIn.nextInt();
        int x[] = new int[n];
        double ave = 0;
        for(int i = 0; i < n; i++){
          x[i] = stdIn.nextInt();
          ave += x[i];
        }
        int p = 0;
        ave = ave/(double)n;
        if(ave*10 % 10 >= 5) p = (int)(ave+1);
        else p = (int)ave;

        int ans = 0;
        for(int i = 0; i < n; i++)
          ans += (x[i] - p) * (x[i] - p);

        System.out.println(ans);
    } main {
        Scanner stdIn = new Scanner(System.in);
        int n = stdIn.nextInt();
        int x[] = new int[n];
        double ave = 0;
        for(int i = 0; i < n; i++){
          x[i] = stdIn.nextInt();
          ave += x[i];
        }
        int p = 0;
        ave = ave/(double)n;
        if(ave*10 % 10 >= 5) p = (int)(ave+1);
        else p = (int)ave;

        int ans = 0;
        for(int i = 0; i < n; i++)
          ans += (x[i] - p) * (x[i] - p);

        System.out.println(ans);
    } Scanner stdIn = new Scanner(System.in); stdIn new Scanner(System.in) int n = stdIn.nextInt(); n stdIn.nextInt() stdIn.nextInt stdIn int x[] = new int[n]; x new int[n] n double ave = 0; ave 0 for(int i = 0; i < n; i++){
          x[i] = stdIn.nextInt();
          ave += x[i];
        } int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
          x[i] = stdIn.nextInt();
          ave += x[i];
        } {
          x[i] = stdIn.nextInt();
          ave += x[i];
        } x[i] = stdIn.nextInt() x[i] x i stdIn.nextInt() stdIn.nextInt stdIn ave += x[i] ave x[i] x i int p = 0; p 0 ave = ave/(double)n ave ave/(double)n ave (double)n if(ave*10 % 10 >= 5) p = (int)(ave+1);
        else p = (int)ave; ave*10 % 10 >= 5 ave*10 % 10 ave*10 ave 10 10 5 p = (int)(ave+1) p (int)(ave+1) ave 1 p = (int)ave p (int)ave int ans = 0; ans 0 for(int i = 0; i < n; i++)
          ans += (x[i] - p) * (x[i] - p); int i = 0; int i = 0; i 0 i < n i n i++ i++ i ans += (x[i] - p) * (x[i] - p); ans += (x[i] - p) * (x[i] - p) ans (x[i] - p) * (x[i] - p) (x[i] - p) x[i] x i p (x[i] - p) x[i] x i p System.out.println(ans) System.out.println System.out System System.out ans String[] args args
import java.util.*;

class Main{
    public static void sort(int[] x){
      for(int i = 0; i < x.length; i++){
        for(int j = i+1; j < x.length; j++){
          if(x[i] > x[j]){
            int  t = x[i];
            x[i] = x[j];
            x[j] = t;
          }
        }
      }
    }
    public static void main(String[] args) {
        Scanner stdIn = new Scanner(System.in);
        int n = stdIn.nextInt();
        int x[] = new int[n];
        double ave = 0;
        for(int i = 0; i < n; i++){
          x[i] = stdIn.nextInt();
          ave += x[i];
        }
        int p = 0;
        ave = ave/(double)n;
        if(ave*10 % 10 >= 5) p = (int)(ave+1);
        else p = (int)ave;

        int ans = 0;
        for(int i = 0; i < n; i++)
          ans += (x[i] - p) * (x[i] - p);

        System.out.println(ans);
    }
}