#include <bits/stdc++.h>
using namespace std;
int min_candies(vector<int>& a) {
  int first = a[0];
  int count = 0;
  int max = *max_element(a.begin(), a.end());
  while (max != first) {
    int i = distance(a.begin(), max_element(a.begin(), a.end()));
    a[i]--;
    a[0]++;
    count++;
    max = *max_element(a.begin(), a.end());
    first = a[0];
  }
  int second_max = *max_element(a.begin() + 1, a.end());
  if (second_max == first) return ++count;
  return count;
}
int main() {
  int N;
  cin >> N;
  vector<int> a;
  for (int i = 0; i < N; i++) {
    int tmp;
    cin >> tmp;
    a.push_back(tmp);
  }
  cout << min_candies(a) << endl;
  return 0;
}
