#include <bits/stdc++.h>
int main() {
  register int n, tmp, o, maxpos, maxval = -1, a[110];
  scanf("%d %d", &n, &tmp);
  o = tmp;
  for (register int i = 1; i < n; ++i) {
    scanf("%d", &a[i]);
    if (a[i] > maxval) maxval = a[i], maxpos = i;
  }
  while (a[maxpos] >= tmp) {
    --a[maxpos], ++tmp, maxval = -1;
    for (register int i = 1; i < n; ++i)
      if (a[i] > maxval) maxval = a[i], maxpos = i;
  }
  return !printf("%d\n", tmp - o);
}
