#include <bits/stdc++.h>
using namespace std;
void run() {
  int n;
  cin >> n;
  vector<long long> al(n);
  for (int i = 0; i < n; i++) {
    cin >> al[i];
  }
  long long sum = 0;
  while (true) {
    long long id = 0;
    long long maxi = 0;
    for (int i = 1; i < n; i++) {
      if (al[i] > maxi) {
        maxi = al[i];
        id = i;
      }
    }
    if (al[0] > maxi)
      break;
    else {
      al[0]++;
      al[id]--;
      sum++;
    }
  }
  cout << sum << "\n";
}
int main() {
  cout << fixed << setprecision(16);
  run();
  return 0;
}
