#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, a, x, sum = 0;
  vector<int> v;
  cin >> n;
  int cnt = n - 2;
  cin >> x;
  ;
  for (int i = 1; i < n; i++) {
    cin >> a;
    v.push_back(a);
  }
  sort(v.begin(), v.end());
  if (n == 2) {
    if (x < v[0]) {
      while (x <= v[0]) {
        x++;
        v[0]--;
        sum++;
      }
      cout << sum << endl;
      return 0;
    } else if (x == v[0]) {
      cout << 1 << endl;
      return 0;
    }
  } else {
    while (x <= v[n - 2]) {
      sum++;
      v[n - 2]--;
      x++;
      sort(v.begin(), v.end());
    }
  }
  cout << sum << endl;
  return 0;
}
