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

using namespace std;



#define F first

#define S second

#define FOR(i,a,b) for (int i = (a); i <= (b); ++i)

#define NFOR(i,a,b) for(int i = (a); i >= (b); --i)

#define all(x) (x).begin(), (x).end()

#define sz(x) int(x.size())

typedef long long ll; typedef pair <int, int> ii; typedef vector <int> vi; const int inf = 1e9 + 7;

#define pr(...) dbs(#__VA_ARGS__, __VA_ARGS__)

template <class T> void dbs(string str, T t) {cout << str << " : " << t << endl;}

template <class T, class... S> void dbs(string str, T t, S... s) {int idx = str.find(','); cout << str.substr(0, idx) << " : " << t << ","; dbs(str.substr(idx + 1), s...);}

template <class S, class T>ostream& operator <<(ostream& os, const pair<S, T>& p) {return os << "(" << p.first << ", " << p.second << ")";}

template <class T>ostream& operator <<(ostream& os, const vector<T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}

template <class T>ostream& operator <<(ostream& os, const set<T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}

template <class S, class T>ostream& operator <<(ostream& os, const map<S, T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}

template <class T> void prc(T a, T b) {cout << "["; for (T i = a; i != b; ++i) {if (i != a) cout << ", "; cout << *i;} cout << "]";cout<<endl;}



int main()

{

	ios::sync_with_stdio(0); cin.tie(0);



	ll n; cin >> n; vector<ll> a(n);

	FOR (i, 0, n - 1) cin >> a[i];





	auto f = [&] (ll x) {

		ll alpha = n - 1 - x;

		ll req = 0;

		FOR (i, 0, n - 1) if (a[i] > alpha) req += (a[i] - alpha + n) / (n + 1);

		return req <= x;

	};



	ll st = 0, en = 1e18;



	// FOR (i, 0, 200) pr(i, f(i));



	while (st < en) {

		ll mid = (st + en) >> 1;

		bool can = false;

		FOR (i, 0, n*n) can |= f(mid + i);

		if (can) en = mid;

		else st = mid + 1;

	}



	FOR (i, 0, n*n) if (f(st + i)) {

		cout << st + i;

		return 0;

	}



	return 0;

}


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

using namespace std;



#define F first

#define S second

#define FOR(i,a,b) for (int i = (a); i <= (b); ++i)

#define NFOR(i,a,b) for(int i = (a); i >= (b); --i)

#define all(x) (x).begin(), (x).end()

#define sz(x) int(x.size())

typedef long long ll; typedef pair <int, int> ii; typedef vector <int> vi; const int inf = 1e9 + 7;

#define pr(...) dbs(#__VA_ARGS__, __VA_ARGS__)

template <class T> void dbs(string str, T t) {cout << str << " : " << t << endl;}

template <class T, class... S> void dbs(string str, T t, S... s) {int idx = str.find(','); cout << str.substr(0, idx) << " : " << t << ","; dbs(str.substr(idx + 1), s...);}

template <class S, class T>ostream& operator <<(ostream& os, const pair<S, T>& p) {return os << "(" << p.first << ", " << p.second << ")";}

template <class T>ostream& operator <<(ostream& os, const vector<T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}

template <class T>ostream& operator <<(ostream& os, const set<T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}

template <class S, class T>ostream& operator <<(ostream& os, const map<S, T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}

template <class T> void prc(T a, T b) {cout << "["; for (T i = a; i != b; ++i) {if (i != a) cout << ", "; cout << *i;} cout << "]";cout<<endl;}



int main()

{

	ios::sync_with_stdio(0); cin.tie(0);



	ll n; cin >> n; vector<ll> a(n);

	FOR (i, 0, n - 1) cin >> a[i];





	auto f = [&] (ll x) {

		ll alpha = n - 1 - x;

		ll req = 0;

		FOR (i, 0, n - 1) if (a[i] > alpha) req += (a[i] - alpha + n) / (n + 1);

		return req <= x;

	};



	ll st = 0, en = 1e18;



	// FOR (i, 0, 200) pr(i, f(i));



	while (st < en) {

		ll mid = (st + en) >> 1;

		bool can = false;

		FOR (i, 0, n) can |= f(mid + i);

		if (can) en = mid;

		else st = mid + 1;

	}



	FOR (i, 0, n) if (f(st + i)) {

		cout << st + i;

		return 0;

	}



	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 ;

}