#include <bits/stdc++.h>
using namespace std;
long long i, j, k, T, t = 1, l, m, n, x, y, a[1000000];
int main() {
  cin >> n;
  for (i = 0; i < n; i++) {
    cin >> a[i];
  }
  int limak = a[0];
  sort(a, a + n);
  int maxx = a[n - 1];
  int c = 0;
  if ((limak == maxx) && (limak != a[n - 2]))
    cout << 0 << endl;
  else {
    while (limak <= a[n - 1]) {
      limak++;
      a[n - 1]--;
      sort(a, a + n);
      c++;
    }
    cout << c << endl;
  }
  return 0;
}
