#include <bits/stdc++.h>
int n, p, ans;
int v[111];
int get_max() {
  int res = 1;
  for (int i = 2; i < n; i++)
    if (v[res] < v[i]) res = i;
  return res;
}
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) scanf("%d", &v[i]);
  ans = 0;
  p = get_max();
  while (v[p] >= v[0]) {
    v[0]++;
    ans++;
    v[p]--;
    p = get_max();
  }
  printf("%d\n", ans);
  return 0;
}
