#include <bits/stdc++.h>
using namespace std;
long long inline ipow(long long a, long long b, long long m) {
  long long val = 1;
  a %= m;
  while (b) {
    if (b & 01) val = (val * a) % m;
    b >>= 1;
    a = (a * a) % m;
  };
  return val % m;
}
long long inline ipow(long long a, long long b) {
  long long val = 1;
  while (b) {
    if (b & 01) val = (val * a);
    b >>= 1;
    a = (a * a);
  };
  return val;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  clock_t tStart = clock();
  int n;
  cin >> n;
  n--;
  int a;
  cin >> a;
  vector<int> v;
  for (int i = 0; i < n; ++i) {
    int dum;
    cin >> dum;
    v.push_back(dum);
  }
  sort(v.rbegin(), v.rend());
  int ans = 0;
  while (1) {
    if (a > v[0]) break;
    a++;
    ans++;
    v[0]--;
    sort(v.rbegin(), v.rend());
  }
  cout << ans << endl;
  return 0;
}
