#include <bits/stdc++.h>
using namespace std;
const int maxn = 1000;
int f[maxn];
int a[maxn];
int main() {
  int n;
  while (scanf("%d", &n) != EOF) {
    int x;
    memset(a, 0, sizeof(a));
    scanf("%d", &x);
    n--;
    for (int i = 0; i < n; i++) scanf("%d", &f[i]);
    sort(f, f + n);
    if (x > f[n - 1]) {
      printf("0\n");
      continue;
    }
    int k = 0;
    for (int i = n - 1; i >= 0; i--) {
      if (f[i] >= x) a[k++] = f[i];
    }
    sort(a, a + k);
    int ans = 0;
    int flag = 0;
    int cnt = a[k - 1];
    while (x <= cnt) {
      ans++;
      x++;
      cnt--;
      a[k - 1] = cnt;
      sort(a, a + k);
      cnt = a[k - 1];
    }
    printf("%d\n", ans);
  }
  return 0;
}
