#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int i, win, ara[n], moves = 0;
  cin >> win;
  n--;
  for (i = 1; i <= n; i++) cin >> ara[i];
  sort(ara + 1, ara + n + 1);
  while (win <= ara[n]) {
    win++;
    moves++;
    ara[n]--;
    sort(ara + 1, ara + n + 1);
  }
  cout << moves << endl;
}
