#include <bits/stdc++.h>
int main() {
  int n, a[1010], temp, lamak, maxin, max, i, j;
  long int count;
  while (scanf("%d", &n) != EOF) {
    count = 0;
    for (i = 0; i < n; i++) {
      scanf("%d", &a[i]);
    }
  again:
    max = 0;
    for (i = 0; i < n; i++) {
      if (a[i] >= max) {
        max = a[i];
        maxin = i;
      }
    }
    if (max > a[0]) {
      a[maxin] = a[maxin] - 1;
      a[0] = a[0] + 1;
      count = count + 1;
      goto again;
    }
    if (max == a[0] && maxin != 0) {
      a[maxin] = a[maxin] - 1;
      a[0] = a[0] + 1;
      count = count + 1;
      printf("%ld\n", count);
    } else {
      printf("%ld\n", count);
    }
  }
  return 0;
}
