import std.algorithm;
import std.array;
import std.ascii;
import std.bigint;
import std.complex;
import std.container;
import std.conv;
import std.functional;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

auto readInts() {
	return array(map!(to!int)(readln().strip().split()));
}
auto readInt() {
	return readInts()[0];
}
auto readLongs() {
	return array(map!(to!long)(readln().strip().split()));
}
auto readLong() {
	return readLongs()[0];
}

void readlnTo(T...)(ref T t) {
    auto s = readln().split();
    assert(s.length == t.length);
    foreach(ref ti; t) {
        ti = s[0].to!(typeof(ti));
        s = s[1..$];
    }
}

const real eps = 1e-10;

const long p = 1_000_000_000 + 7;

long f(ref long[] a) {
    long n = a.length;
    if(a[0] <= 3*n) {
        long ans = 0;
        while(a[0] >= n) {
            a[0] -= n;
            a[1..$] += 1;
            a.sort!"a > b"();
            ++ans;
        }
        return ans;
    }
    long j = a.assumeSorted!("a > b").lowerBound(a[0]-n-1-1).array.length;
    if(j == n) {
        long x = a[0] - 2*n;
        foreach(i; iota(n)) {
            a[i] -= x;
        }
        a.sort!"a > b"();
        return x*n;
    }
    long l = 0;
    long u = long.max/100;
    while(l+1 < u) {
        long m = (l+u)/2;
        if(a[j-1] - m*(n-(j-1)) >= n && a[0]-m*(n-(j-1)) > a[j] + m*j) {
            l = m;
        } else {
            u = m;
        }
    }
    foreach(i; iota(n)) {
        if(i < j) {
            a[i] -= l*(n-(j-1));
        } else {
            a[i] += l*j;
        }
    }
    a.sort!"a > b"();
    return l*j;
}

void main(){
    auto n = readLong();
    auto a = readLongs();
    a.sort!"a > b"();
    long ans = 0;
    while(a[0] >= n) {
        ans += f(a);
    }
    writeln(ans);
}

