#include <bits/stdc++.h>
int n, max, a[1010], maxn, pp, k;
int main() {
  scanf("%d", &n);
  scanf("%d", &a[1]);
  if (n == 1) {
    printf("0");
    return 0;
  }
  max = a[1];
  for (int i = 2; i <= n; i++) {
    scanf("%d", &a[i]);
    if (a[i] > maxn) maxn = a[i];
  }
  if (a[1] > maxn)
    printf("0");
  else {
    for (int i = 1; i <= 10000000; i++) {
      maxn = 0;
      for (int j = 2; j <= n; j++)
        if (a[j] >= maxn) {
          maxn = a[j];
          pp = j;
        }
      a[pp]--;
      a[1]++;
      k++;
      for (int j = 2; j <= n; j++)
        if (a[j] >= maxn) {
          maxn = a[j];
          pp = j;
        }
      if (a[1] > a[pp]) {
        printf("%d", k);
        break;
      }
    }
  }
  return 0;
}
