public void solve() throws IOException {
    int n = nextInt();
    int[] a = new int[n];
    for (int x = 0; x < n; x++)
      a[x] = nextInt();
    Arrays.sort(a);
    int rounds = 0;
    while (a[n - 1] > 0) {
      if (a[0] == 0) {
        rounds += a[n - 1];
        break;
      }
      int diff = a[1] - a[0] + 1;
      for (int x = 1; x < n; x++)
        a[x] -= diff;
      Arrays.sort(a);
      rounds += diff;
    }

    System.out.println(rounds);
  }