#include <bits/stdc++.h>
using namespace std;
int arr[100 + 10];
int main() {
  int n, m, k, d, tem1, tem2, tem3, tem4, sum = 0, ans = 0;
  string s, c;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> arr[i];
  }
  for (int i = 0; i < 90000; i++) {
    m = arr[0] + i;
    int e = i;
    int y = 0;
    for (int j = 1; j < n; j++) {
      if (arr[j] >= m) {
        y += arr[j] - m + 1;
      }
    }
    if (y <= i) {
      cout << i;
      return 0;
    }
  }
  return 0;
}
