import java.util.*;
public class Main{
  public static void main (String args[]){
    Scanner sc = new Scanner(System.in);
    
    int n = sc.nextInt();
    double[] list = new double[n];
    
    double sum = 0;
    for (int i = 0; i < n; i++){
      list[i] = sc.nextDouble();
      sum += list[i];
    }
    
    long p = Math.round(sum/n);
    
    double ans = 0;
    for (int i = 0; i < n; i++){
      double d = Math.pow(list[i]-p, 2);
      ans += d;
    }
    
    System.out.print((int)ans);
    
  }
} import java.util.*; util.* java public class Main{
  public static void main (String args[]){
    Scanner sc = new Scanner(System.in);
    
    int n = sc.nextInt();
    double[] list = new double[n];
    
    double sum = 0;
    for (int i = 0; i < n; i++){
      list[i] = sc.nextDouble();
      sum += list[i];
    }
    
    long p = Math.round(sum/n);
    
    double ans = 0;
    for (int i = 0; i < n; i++){
      double d = Math.pow(list[i]-p, 2);
      ans += d;
    }
    
    System.out.print((int)ans);
    
  }
} Main public static void main (String args[]){
    Scanner sc = new Scanner(System.in);
    
    int n = sc.nextInt();
    double[] list = new double[n];
    
    double sum = 0;
    for (int i = 0; i < n; i++){
      list[i] = sc.nextDouble();
      sum += list[i];
    }
    
    long p = Math.round(sum/n);
    
    double ans = 0;
    for (int i = 0; i < n; i++){
      double d = Math.pow(list[i]-p, 2);
      ans += d;
    }
    
    System.out.print((int)ans);
    
  } main {
    Scanner sc = new Scanner(System.in);
    
    int n = sc.nextInt();
    double[] list = new double[n];
    
    double sum = 0;
    for (int i = 0; i < n; i++){
      list[i] = sc.nextDouble();
      sum += list[i];
    }
    
    long p = Math.round(sum/n);
    
    double ans = 0;
    for (int i = 0; i < n; i++){
      double d = Math.pow(list[i]-p, 2);
      ans += d;
    }
    
    System.out.print((int)ans);
    
  } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int n = sc.nextInt(); n sc.nextInt() sc.nextInt sc double[] list = new double[n]; list new double[n] n double sum = 0; sum 0 for (int i = 0; i < n; i++){
      list[i] = sc.nextDouble();
      sum += list[i];
    } int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
      list[i] = sc.nextDouble();
      sum += list[i];
    } {
      list[i] = sc.nextDouble();
      sum += list[i];
    } list[i] = sc.nextDouble() list[i] list i sc.nextDouble() sc.nextDouble sc sum += list[i] sum list[i] list i long p = Math.round(sum/n); p Math.round(sum/n) Math.round Math sum/n sum n double ans = 0; ans 0 for (int i = 0; i < n; i++){
      double d = Math.pow(list[i]-p, 2);
      ans += d;
    } int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
      double d = Math.pow(list[i]-p, 2);
      ans += d;
    } {
      double d = Math.pow(list[i]-p, 2);
      ans += d;
    } double d = Math.pow(list[i]-p, 2); d Math.pow(list[i]-p, 2) Math.pow Math list[i]-p list[i] list i p 2 ans += d ans d System.out.print((int)ans) System.out.print System.out System System.out (int)ans String args[] args public class Main{
  public static void main (String args[]){
    Scanner sc = new Scanner(System.in);
    
    int n = sc.nextInt();
    double[] list = new double[n];
    
    double sum = 0;
    for (int i = 0; i < n; i++){
      list[i] = sc.nextDouble();
      sum += list[i];
    }
    
    long p = Math.round(sum/n);
    
    double ans = 0;
    for (int i = 0; i < n; i++){
      double d = Math.pow(list[i]-p, 2);
      ans += d;
    }
    
    System.out.print((int)ans);
    
  }
} public class Main{
  public static void main (String args[]){
    Scanner sc = new Scanner(System.in);
    
    int n = sc.nextInt();
    double[] list = new double[n];
    
    double sum = 0;
    for (int i = 0; i < n; i++){
      list[i] = sc.nextDouble();
      sum += list[i];
    }
    
    long p = Math.round(sum/n);
    
    double ans = 0;
    for (int i = 0; i < n; i++){
      double d = Math.pow(list[i]-p, 2);
      ans += d;
    }
    
    System.out.print((int)ans);
    
  }
} Main
import java.util.*;
public class Main{
  public static void main (String args[]){
    Scanner sc = new Scanner(System.in);
    
    int n = sc.nextInt();
    double[] list = new double[n];
    
    double sum = 0;
    for (int i = 0; i < n; i++){
      list[i] = sc.nextDouble();
      sum += list[i];
    }
    
    long p = Math.round(sum/n);
    
    double ans = 0;
    for (int i = 0; i < n; i++){
      double d = Math.pow(list[i]-p, 2);
      ans += d;
    }
    
    System.out.print((int)ans);
    
  }
}