#include <bits/stdc++.h>
using namespace std;
int getNumberOfAdditionalVotes(vector<int> array) {
  if (array.size() < 1) {
    return -1;
  }
  int x = array[0];
  int count = 0;
  array[0] = array[array.size() - 1];
  array.pop_back();
  sort(array.begin(), array.end());
  while (x <= array[array.size() - 1]) {
    array[array.size() - 1]--;
    x++;
    count++;
    sort(array.begin(), array.end());
  }
  return count;
}
int main() {
  int n;
  vector<int> array;
  cin >> n;
  int value;
  for (int i = 0; i < n; i++) {
    cin >> value;
    array.push_back(value);
  }
  cout << getNumberOfAdditionalVotes(array);
  return 0;
}
