#include <bits/stdc++.h>
using namespace std;
int n, maxx, ans;
int num[105];
int d[1005];
int main() {
  memset(d, 0, sizeof(d));
  scanf("%d", &n);
  maxx = ans = 0;
  for (int i = 0; i < n; i++) {
    scanf("%d", &num[i]);
    if (num[i] > maxx) maxx = num[i];
    d[num[i]]++;
  }
  if (num[0] == maxx && d[maxx] == 1) {
    cout << "0" << endl;
    return 0;
  }
  while (num[0] <= maxx) {
    d[maxx]--;
    d[maxx - 1]++;
    if (d[maxx] == 0) maxx--;
    num[0]++;
    ans++;
  }
  cout << ans << endl;
  return 0;
}
