#include <bits/stdc++.h>
using namespace std;



int main(){
  int N,avg,ans=0;
  cin >> N;
  vector<int> x(N);
  double sum=0.0;
  for(int i=0;i<N;++i) cin >> x[i];
  for(int i=0;i<N;++i) sum += double(x[i]);
  avg = round(sum/N);
  for(int i=0;i<N;++i){
    ans += pow((x[i]-avg),2);
  }
  cout << ans << endl;
}