#include <bits/stdc++.h>
int cmpfunc(const void* a, const void* b) { return (*(int*)a - *(int*)b); }
int main() {
  int n, i, k = 0, sum = 0;
  scanf("%d", &n);
  int ara[n], a[n - 1];
  scanf("%d", &ara[0]);
  for (i = 1; i < n; i++) {
    scanf("%d", &ara[i]);
    if (ara[i] >= ara[0]) a[k++] = ara[i];
  }
  if (k == 0) {
    printf("0");
    return 0;
  }
  qsort(a, k, sizeof(int), cmpfunc);
  while (ara[0] <= a[k - 1]) {
    a[k - 1]--;
    sum++;
    ara[0]++;
    qsort(a, k, sizeof(int), cmpfunc);
  }
  printf("%d", sum);
  return 0;
}
