#include <bits/stdc++.h>
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define rep(i,N) for(long long i = 0; i < (long long)(N); i++)
#define repr(i,N) for(long long i = (long long)(N) - 1; i >= 0; i--)
#define rep1(i,N) for(long long i = 1; i <= (long long)(N) ; i++)
#define repr1(i,N) for(long long i = (N) ; (long long)(i) > 0 ; i--)
#define each(x,v) for(auto& x : v)
#define all(v) (v).begin(),(v).end()
#define sz(v) ((int)(v).size())
#define ini(...) int __VA_ARGS__; in(__VA_ARGS__)
#define inl(...) long long __VA_ARGS__; in(__VA_ARGS__)
#define ins(...) string __VA_ARGS__; in(__VA_ARGS__)
using namespace std; void solve();
using ll = long long; template<class T = ll> using V = vector<T>;
using vi = V<int>; using vl = V<>; using vvi = V< V<int> >;
constexpr int inf = 1001001001; constexpr ll infLL = (1LL << 61) - 1;
struct IoSetupNya {IoSetupNya() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); cerr << fixed << setprecision(7);} } iosetupnya;
template<typename T, typename U> inline bool amin(T &x, U y) { return (y < x) ? (x = y, true) : false; }
template<typename T, typename U> inline bool amax(T &x, U y) { return (x < y) ? (x = y, true) : false; }
template<typename T, typename U> ostream& operator <<(ostream& os, const pair<T, U> &p) { os << p.first << " " << p.second; return os; }
template<typename T, typename U> istream& operator >>(istream& is, pair<T, U> &p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator <<(ostream& os, const vector<T> &v) { int s = (int)v.size(); rep(i,s) os << (i ? " " : "") << v[i]; return os; }
template<typename T> istream& operator >>(istream& is, vector<T> &v) { for(auto &x : v) is >> x; return is; }
void in(){} template <typename T,class... U> void in(T &t,U &...u){ cin >> t; in(u...);}
void out(){cout << "\n";} template <typename T,class... U> void out(const T &t,const U &...u){ cout << t; if(sizeof...(u)) cout << " "; out(u...);}
template<typename T>void die(T x){out(x); exit(0);}
#ifdef NyaanDebug
  #include "NyaanDebug.h"
  #define trc(...) do { cerr << #__VA_ARGS__ << " = "; dbg_out(__VA_ARGS__);} while(0)
  #define trca(v,N) do { cerr << #v << " = "; array_out(v , N);} while(0)
  #define trcc(v) do { cerr << "name : " << #v << "\n"; int cnt = 0; each(x , v){cerr << (cnt++) << " : "; trc(x); } } while(0)
#else
  #define trc(...)
  #define trca(...)
  #define trcc(...)
  int main(){solve();}
#endif

#define inc(...) char __VA_ARGS__; in(__VA_ARGS__)
#define in2(s,t)   rep(i,sz(s)){in(s[i] , t[i]);}
#define in3(s,t,u) rep(i,sz(s)){in(s[i] , t[i] , u[i]);}
using vd = V<double>; using vs = V<string>; using vvl = V< V<> >;
template<typename T,typename U>ll ceil(T a,U b){return (a + b - 1) / b;}

using P = pair<ll,ll>; using vp = V<P>;
constexpr int MOD = /**/ 1000000007; //*/ 998244353;
//////////////////

void solve(){
  ini(N);
  vl a(N);in(a);

  ll ans = infLL;
  rep(i,101){
    ll cur = 0;
    each(x,a) cur += (x-i)*(x-i);
    amin(ans,cur);
  }
  out(ans);
}


/*

// c++17での名前衝突を避けるためdefine
#define gcd nyagcd
#define lcm nyalcm
ll nyagcd(ll x, ll y){
  ll z;
  if(x > y) swap(x,y);
  while(x){
    x = y % (z = x); y = z;
  }    
  return y;
}
ll nyalcm(ll x,ll y){
  return 1LL * x / gcd(x,y) * y;
}

// 素数判定 O( sqrt(N) log log N )
// 0からNに対して素数->1、それ以外->0の配列を返す関数
vector<int> Primes(int N){
  vector<int> A(N + 1 , 1);
  A[0] = A[1] = 0;
  for(int i = 2; i * i <= N ; i++) 
    if(A[i]==1) for(int j = i << 1 ; j <= N; j += i) A[j] = 0;
  return A;
}

// 因数 O( sqrt(N) log log N )
// 0からNに対して素数->1、それ以外->最小の素数である因数、の配列を返す
vector<int> Factors(int N){
  vector<int> A(N + 1 , 1);
  A[0] = A[1] = 0;
  for(int i = 2; i * i <= N ; i++) 
    if(A[i]==1) for(int j = i << 1 ; j <= N; j += i) A[j] = i;
  return A;
}

// オイラーのトーシェント関数 φ(N)=(Nと互いに素なN以下の自然数の個数)
vector<int> EulersTotientFunction(int N){
  vector<int> ret(N + 1 , 0);
  for(int i = 0; i <= N ; i++) ret[i] = i; 
  for(int i = 2 ; i <= N ; i++){
    if(ret[i] == i)
      for(int j = i; j <= N; j += i) ret[j] = ret[j] / i * (i - 1);
  }
  return ret;
}

// 約数列挙 O(sqrt(N))
// Nの約数を列挙した配列を返す
vector<long long> Divisor(long long N){
  vector<long long> v;
  for(long long i = 1; i * i <= N ; i++){
    if(N % i == 0){
      v.push_back(i);
      if(i * i != N) v.push_back(N / i);
    }
  }
  return v;
}

// 素因数分解
// 因数をkey、そのべきをvalueとするmapを返す
// ex) N=12 -> m={ (2,2) , (3,1) }
map<long long,int> PrimeFactors(long long N){
  map<long long,int> m;
  for(long long i=2; i * i <= N; i++)
    while(N % i == 0) m[i]++ , N /= i;
  if(N >= 2) m[N]++;
  return m;
}

// 原始根 modでrが原始根かどうかを調べる
bool PrimitiveRoot(long long r , long long mod){
  r %= mod; if(r == 0) return false;
  auto modpow = [](long long a,long long b,long long m)->long long{
    a %= m; long long ret = 1;
    while(b){
      if(b & 1) ret = a * ret % m;
      a = a * a % m;
      b >>= 1;
    }
    return ret;
  };
  map<long long,int> m = PrimeFactors(mod - 1);
  each(x , m){
    if(modpow(r , (mod - 1) / x.fi , mod ) == 1) return false;
  }
  return true;
}

// 拡張ユークリッド ax+by=gcd(a,b)の解
// 返り値　最大公約数
long long extgcd(long long a,long long b, long long &x, long long &y){
  if(b == 0){
    x = 1; y = 0; return a;
  }
  long long d = extgcd(b , a%b , y , x);
  y -= a / b * x;
  return d;
}

// ブール代数ライブラリ
// Point. 乗法の単位元は-1 (UNIT & a = aを満たすUNITであるため)
struct BA{
  unsigned long long x;
  BA(): x(0){}
  BA(unsigned long long y):x(y){}
  
  BA operator += (const BA &p){
    x = x ^ p.x;
    return (*this);
  }
  BA operator *= (const BA &p){
    x = x & p.x;
    return (*this);
  }

  BA operator+(const BA &p)const {return BA(*this) += p;}
  BA operator*(const BA &p)const {return BA(*this) *= p;}
  bool operator==(const BA &p) const { return x == p.x; }
  bool operator!=(const BA &p) const { return x != p.x; }

  friend ostream &operator<<(ostream &os,const BA &p){
    return os << p.x;
  }
  friend istream &operator>>(istream &is, BA &a){
    unsigned int t;
    is >> t;
    a = BA(t);
    return (is);
  }
};

void solve(){
  inl(K , Q);
  vl d(K); in(d);
  vl n(Q),x(Q),m(Q);
  in3(n,x,m);

  auto mkrui = [](auto v) -> decltype(v){
    decltype(v) ret(v.size() + 1);
    for(int i = 0 ; i < int(v.size()) ; i++) 
      ret[i + 1] = ret[i] + v[i];
    return ret;
  };
  auto drui = mkrui(d);
  ll D = drui[K];

  rep(q,Q){
    ll N = n[q];
    ll X = x[q];
    ll M = m[q];
    trc(N,X,M);
    if(M > 5000){
      // 最後の項を出して頑張る
      

    }
    ll ans = 0;

    // % K が 0 の時
    
    ll g = gcd(D , M);
    vl cnt(M , 0);
    {
      ll leap = M / g;
      ll nya = (N + K - 1) / K;
      trc(leap , nya);
      rep(i , leap){
        //if(nya + leap - 1 - i < 0) continue;
        //trc(nya + leap - 1 - i);
        ll val = D * i % M;
        cnt[val] += (nya + leap - 1 - i) / leap;
      }
    }
    cnt.resize(M * 2);
    rep(i,M) cnt[i + M] = cnt[i];

    auto crui = mkrui(cnt);
    // i ずれ
    rep(i , K){
      // are
      if(i != 0 && i % K == N % K){
        ll nya = (N + K - 1) / K;
        cnt[(D % M * (nya - 1)) % M]--;
        cnt[(D % M * (nya - 1)) % M + M]--;
        crui = mkrui(cnt);
      }
      //trc(cnt);
     
      // 0超過 B未満
      ll B = M - (d[i] % M);
      // X
      ll offset = (X + drui[i]) % M;
      // [M - offset + 1 , M + B - offset)
      ans += crui[M + B - offset] - crui[M - offset + 1];
      //trc(ans , B , offset);
    }

    out(ans);

    

    

    
  }


}

*/

Measured memory_bytes: 256