// tested by Hightail - https://github.com/dj3500/hightail
import std.stdio, std.string, std.conv, std.algorithm;
import std.range, std.array, std.math, std.typecons, std.container, core.bitop;
import std.datetime, std.bigint;

immutable inf = 2L * 10L^^16;

int n;
long[] a;

void main() {
    scan(n);
    a = readln.split.to!(long[]);

    bool check(long k) {
        auto b = a.dup;
        b[] += k;

        long cnt;

        foreach (i ; 0 .. n) {
            if (b[i] - (n - 1) <= 0) continue;
            cnt += (b[i] - (n - 1) + n) / (n + 1);

            if (cnt > k) {
                return false;
            }
        }

        return true;
    }

    auto ans = new long[](n);
    long btm, top;

    foreach (i ; 0 .. n) {
        btm = -1;
        top = inf;

        while (top - btm > 1) {
            long mid = btm + (top - btm) / 2;

            if (check(n * mid + i)) {
                top = mid;
            }
            else {
                btm = mid;
            }
        }
        ans[i] = n * top + i;
    }

    debug {
        writeln(ans);
    }

    writeln(ans.reduce!min);
}




void scan(T...)(ref T args) {
    string[] line = readln.split;
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}


void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}