#include <bits/stdc++.h>
using namespace std;
vector<int> votes;
int maximum() {
  int maxvotes = -1;
  int ans = -1;
  for (int i = 0; i < votes.size(); i++) {
    if (votes[i] >= maxvotes) {
      maxvotes = votes[i];
      ans = i;
    }
  }
  return ans;
}
int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    int temp;
    cin >> temp;
    votes.push_back(temp);
  }
  int count = 0;
  while (maximum() != 0) {
    int m = maximum();
    int arbit;
    votes[m]--;
    votes[0]++;
    count++;
  }
  cout << count << endl;
}
