#include<bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<(int)N;i++)
int main()
{
  int N,mean1=0,mean2=0,sum=0,y=0;
  cin>>N;
  vector<int> X(N,0);
  rep(i,N){cin>>X.at(i);sum+=X.at(i);}
  y=sum/N;
  rep(i,N){mean1+=pow(X.at(i)-y,2);mean2+=pow(X.at(i)-y-1,2);}
  cout<<min(mean1,mean2)<<endl;
}