#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  scanf("%d", &n);
  int a[n];
  for (int i = 0; i < n; i++) scanf("%d", &a[i]);
  sort(a + 1, a + n);
  int cur = a[0];
  int cnt = 0;
  while (a[n - 1] >= cur) {
    cnt++;
    cur++;
    a[n - 1]--;
    if (a[n - 1] < a[n - 2]) {
      int tmp = a[n - 1], i;
      for (i = n - 2; i > 0 && a[i] > tmp; i--) a[i + 1] = a[i];
      a[i + 1] = tmp;
    }
  }
  printf("%d\n", cnt);
  return 0;
}
