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