// Original C++ solution (slower):
#include<bits/stdc++.h>

#define INF 1e9

#define llINF 1e18

#define MOD 1000000007

#define pb push_back

#define mp make_pair 

#define F first

#define S second

#define ll long long

#define vi vector<ll>

#define vvi vector<vi>

#define substr(s,f,t) (s.substr(f-1,t-f+1))

#define ALL(a) (a).begin(),(a).end()

#define Yes(hoge) cout<<((hoge)?"Yes":"No")<<endl;

#define YES(hoge) cout<<((hoge)?"YES":"NO")<<endl;

using namespace std;

struct Grid{ll x,y,t;};

struct Edge{ll to,cost;};

struct Graph{vector<vector<Edge>>E;int V;

  const ll Inf = llINF;const int MAX_V=201010;vector<ll>d;

  Graph(int n):E(n){d.resize(MAX_V);E.resize(n);V=n;}

  void init(){for(int i=0;i<MAX_V;i++)d[i]=Inf;}

  void add_edge(ll from,ll to,ll cost){E[from].pb({to,cost});}

};

int main(){

  cin.tie(0);

  ios::sync_with_stdio(false);

  ll n;cin>>n;

  priority_queue<ll>que;

  for(int i=0;i<n;i++){

    ll a;cin>>a;

    que.push(a);

  }

  ll ans=0;

  while(1){

    if((que.top())<n)break;

    ll num=que.top();

    que.pop();

    ll cnt=(num)/n;

    num-=((num)/n)*n;

    vi numm;numm.pb(num);

    ans+=cnt;

    for(int i=0;i<n-1;i++){

      numm.pb(cnt+que.top());

      que.pop();

    }

    for(int i=0;i<n;i++){que.push(numm[i]);}

  }

  cout<<ans<<endl;

  return 0;

}


// Optimized solution to the same problem (faster):
#include<bits/stdc++.h>

#define INF 1e9

#define llINF 1e18

#define MOD 1000000007

#define pb push_back

#define mp make_pair 

#define F first

#define S second

#define ll long long

#define ull unsigned long long

#define vi vector<ll>

#define vvi vector<vi>

#define DBG_N(hoge) cerr<<"!"<<" "<<(hoge)<<endl;

#define DBG cerr<<"!"<<endl;

#define BITLE(n) (1LL<<((ll)n))

#define BITCNT(n) (__builtin_popcountll(n))

#define SUBS(s,f,t) ((s).substr((f)-1,(t)-(f)+1))

#define ALL(a) (a).begin(),(a).end()

using namespace std;



int main(){

  cin.tie(0);

  ios::sync_with_stdio(false);

  ll n;cin>>n;

  priority_queue<ll>que;

  for(int i=0;i<n;i++){

    ll a;cin>>a;

    que.push(a);

  }

  ll ans=0;

  while(que.top()+ans>=n){

    ll num=que.top()+ans;

    que.pop();

    ll cnt=num/n;

    //cout<<cnt<<endl;

    que.push((num-(num/n)*n)-ans-cnt);

    ans+=cnt;

  }

  cout<<ans<<endl;

  return 0;

}


// Fastest known solution for this problem:
#include <iostream>

//#include <iomanip>

//#include <string>

#include <vector>

//#include <algorithm>

//#include <utility>

//#include <set>

//#include <map>

//#include <queue>

//#include <deque>

//#include <bitset>

//#include <math.h>

using namespace std ;

using ll = long long ;

//using ld = long double ;

using vll = vector<ll> ;

//using vvll = vector<vll> ;

//using vc = vector<char> ;

//using vvc = vector<vc> ;

//using vb = vector<bool> ;

//using vvb = vector<vb> ;

//using pll = pair<ll,ll> ;\



//ll mod = 1000000007 ;

//ll INF = 10000000000 ;

//long double pie = acos(-1) ;



//void yorn(bool a){if(a) cout << "Yes" << endl ; else cout << "No" << endl ;}

//void YorN(bool a){if(a) cout << "YES" << endl ; else cout << "NO" << endl ;}

//ll gcd(long long a,long long b){if(b==0) return a ; return gcd(b,a%b) ;}

//ll lcm(long long a,long long b){return a/gcd(a,b)*b ;}

//ll sa(long long a,long long b){if(a>b) return a-b ; return b-a ;}

//void mysort(vector<long long> &a){sort(a.begin(),a.end()) ;}

//void myrev(vector<long long> &a){reverse(a.begin(),a.end()) ;}





int main(){

	ll n ; cin >> n ;

	vll a(n) ;

	for(auto &i:a) cin >> i ;

	bool ok = true ;

	ll cnt = 0 ;

	while(ok){

		ok = false ;

		ll sum = 0 ;

		for(int i=0;i<n;i++){

			if(a.at(i)>=n){

				sum += a.at(i)/n ;

			}

		}

		ok = (sum!=0) ;

		if(ok){

			cnt += sum ;

			for(int i=0;i<n;i++){

				a.at(i) += (sum-a.at(i)/n)-a.at(i)/n*n ;

			}

		}

	}

	cout << cnt << endl ;

}