#include <bits/stdc++.h>
using namespace std;
int a[111];
int cnt[1111];
int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    if (i != 0) {
      cnt[a[i]]++;
    }
  }
  int limak = a[0];
  int tmp = limak;
  sort(a + 1, a + n);
  if (limak == a[n - 1]) {
    cout << 1 << endl;
    return 0;
  }
  int i = 1000;
  while (1) {
    while (i >= 0 && cnt[i] == 0) i--;
    if (limak > i) {
      cout << limak - tmp << " ";
      return 0;
    } else {
      cnt[i]--;
      cnt[i - 1]++;
      limak++;
    }
  }
}
