#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, indx;
  cin >> n;
  int vote[n + 1];
  for (int i = 0; i < n; i++) {
    cin >> vote[i];
  }
  int sum = 0;
  int temp;
  while (1) {
    indx = max_element(vote, vote + n) - vote;
    if (indx == 0) {
      for (int i = 1; i < n; i++) {
        if (vote[0] == vote[i]) {
          sum++;
          break;
        }
      }
      break;
    }
    vote[indx]--;
    vote[0]++;
    sum++;
  }
  cout << sum << endl;
  return 0;
}
