#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  int vett[N];
  for (int i = 0; i < N; i++) cin >> vett[i];
  int Max, ind, cont = 0;
  do {
    Max = -1;
    for (int i = 0; i < N; i++)
      if (vett[i] >= Max) {
        Max = vett[i];
        ind = i;
      }
    if (ind != 0) {
      vett[ind]--;
      vett[0]++;
      cont++;
    }
  } while (ind != 0);
  cout << cont;
  return 0;
}
