#include <bits/stdc++.h>
using namespace std;
int main(int argc, char const *argv[]) {
  int n, data[1010], t, b, ans = 0, index = -1;
  memset(data, 0, sizeof(data));
  scanf("%d", &n);
  scanf("%d", &b);
  for (int i = 1; i < n; ++i) {
    scanf("%d", &t);
    data[t]++;
    index = max(t, index);
  }
  while (index >= b) {
    while (data[index] > 0 && index >= b) {
      b += 1;
      ans += 1;
      data[index - 1] += 1;
      data[index] -= 1;
    }
    index--;
  }
  printf("%d\n", ans);
  return 0;
}
