#include <bits/stdc++.h>
using namespace std;
const long long N = 1e3 + 5;
const long long M = 1e7 + 5;
const long long mod = 1e9 + 7;
long long MODULAR_POWER(long long a, long long b) {
  if (b == 0) return 1LL;
  long long d = MODULAR_POWER(a, b / 2);
  d *= d;
  d %= mod;
  if (b % 2) d *= a;
  d %= mod;
  return d;
}
long long BINARY_SEARCH(long long a[], long long n, long long key) {
  long long s = 1;
  long long e = n;
  while (s <= e) {
    long long mid = (s + e) / 2;
    if (a[mid] == key)
      return mid;
    else if (a[mid] > key)
      e = mid - 1;
    else
      s = mid + 1;
  }
  return -1;
}
string CONVERT_TO_BINARY(long long s) {
  string res = "";
  while (s != 0) {
    res += (char)('0' + s % 2);
    s /= 2;
  }
  reverse(res.begin(), res.end());
  return res;
}
long long n;
long long a[N];
long long dp[N];
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cout.precision(8);
  cout << fixed;
  cin >> n;
  for (long long i = 1; i <= n; i++) cin >> a[i];
  int b = a[1];
  int res = 0;
  while (1) {
    long long maxi = -1;
    for (long long i = 1; i <= n; i++) {
      maxi = max(maxi, a[i]);
    }
    int ind = -1;
    int cnt = 0;
    for (long long i = 1; i <= n; i++) {
      if (a[i] == maxi) {
        cnt++;
        ind = i;
      }
    }
    if (maxi == a[1] && cnt == 1) {
      break;
    } else {
      res++;
      a[ind]--;
      a[1]++;
    }
  }
  cout << res << endl;
  return 0;
}
