We have a sequence of length N consisting of non-negative integers. Consider performing the following operation on this sequence until the largest element in this sequence becomes N-1 or smaller. (The operation is the same as the one in Problem D.)

* Determine the largest element in the sequence (if there is more than one, choose one). Decrease the value of this element by N, and increase each of the other elements by 1.



It can be proved that the largest element in the sequence becomes N-1 or smaller after a finite number of operations.

You are given the sequence a_i. Find the number of times we will perform the above operation.

Constraints

* 2 ≤ N ≤ 50
* 0 ≤ a_i ≤ 10^{16} + 1000

Input

Input is given from Standard Input in the following format:


N
a_1 a_2 ... a_N


Output

Print the number of times the operation will be performed.

Examples

Input

4
3 3 3 3


Output

0


Input

3
1 0 3


Output

1


Input

2
2 2


Output

2


Input

7
27 0 0 0 0 0 0


Output

3


Input

10
1000 193 256 777 0 1 1192 1234567891011 48 425


Output

1234567894848
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.io.BufferedWriter;
import java.io.Writer;
import java.io.OutputStreamWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.util.NoSuchElementException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author ogiekako
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        MyScanner in = new MyScanner(inputStream);
        MyPrintWriter out = new MyPrintWriter(outputStream);
        TaskE solver = new TaskE();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskE {
        public void solve(int testNumber, MyScanner in, MyPrintWriter out) {
            int N = in.nextInt();
            long[] A = new long[N];
            long sum = 0;
            for (int i = 0; i < N; i++) {
                A[i] = in.nextLong();
                sum += A[i];
            }
            out.println(solve(A));
//        for (long K = Math.max(0, sum - 2500); K <= sum; K++) {
//            boolean ok = true;
//            long Y = 0;
//            for (int i = 0; i < N; i++) {
//                long x = (A[i] + K) / (N + 1);
//                if (A[i] + K - N >= K * (N + 1)) {
//                    ok = false;
//                }
//                Y += x;
//            }
//            if (ok && K == Y) {
//                out.println(K);
//                return;
//            }
//        }
//        throw new RuntimeException();
        }

        private long solve(long[] a) {
            Arrays.sort(a);
            int N = a.length;
            if (a[N - 1] < N) return 0;
            long d = a[N - 1] / N;
            a[N - 1] -= N * d;
            for (int i = 0; i < N - 1; i++) {
                a[i] += d;
            }
            return solve(a) + d;
        }

    }

    static class MyPrintWriter {
        PrintWriter out;

        public MyPrintWriter(OutputStream outputStream) {
            out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(outputStream)));
        }

        public MyPrintWriter(Writer writer) {
            out = new PrintWriter(writer);
        }

        public void println(Object... os) {
            if (os.length == 0) {
                out.println();
                return;
            }
            for (int i = 0; i < os.length - 1; i++) {
                out.print(os[i]);
                out.print(' ');
            }
            out.println(os[os.length - 1]);
        }

        public void close() {
            out.close();
        }

    }

    static class MyScanner {
        private final InputStream in;
        private static final int BUFSIZE = 65536;
        int bufLen;
        int bufPtr;
        byte[] buf = new byte[BUFSIZE];

        public MyScanner(InputStream in) {
            this.in = in;
        }

        public int read() {
            if (bufLen == -1)
                throw new InputMismatchException();
            if (bufPtr >= bufLen) {
                bufPtr = 0;
                try {
                    bufLen = in.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (bufLen <= 0)
                    return -1;
            }
            return buf[bufPtr++];
        }

        public int nextInt() {
            int c = read();
            if (c == -1) throw new NoSuchElementException();
            while (c != '-' && (c < '0' || '9' < c)) {
                c = read();
                if (c == -1) throw new NoSuchElementException();
            }
            if (c == '-') return -nextInt();
            int res = 0;
            do {
                res *= 10;
                res += c - '0';
                c = read();
            } while ('0' <= c && c <= '9');
            return res;
        }

        public long nextLong() {
            int c = read();
            if (c == -1) throw new NoSuchElementException();
            while (c != '-' && (c < '0' || '9' < c)) {
                c = read();
                if (c == -1) throw new NoSuchElementException();
            }
            if (c == '-') return -nextLong();
            long res = 0;
            do {
                res *= 10;
                res += c - '0';
                c = read();
            } while ('0' <= c && c <= '9');
            return res;
        }

    }
}

