#include <bits/stdc++.h>
int main() {
  int n, i, a[105], max, count;
  scanf("%d", &n);
  max = 0;
  count = 0;
  for (i = 0; i < n; i++) {
    scanf("%d", &a[i]);
    if (a[i] >= a[max] && i > 0) max = i;
  }
  while (max != 0) {
    a[0]++;
    a[max]--;
    count++;
    for (i = 0; i < n; i++) {
      if (a[max] <= a[i]) max = i;
    }
  }
  printf("%d\n", count);
  return 0;
}
