#include <bits/stdc++.h>
using namespace std;
const int INF = 2147483647, MOD = 1000 * 1000 * 1000 + 7;
const double eps = 1e-8;
void Error(string err) {
  cout << err;
  cerr << "_" << err << "_";
  exit(0);
}
int gcd(int a, int b) { return (b == 0) ? a : gcd(b, a % b); }
const int sz = 10 * 1000;
int arr[sz];
int main() {
  int n;
  cin >> n;
  for (int i = 0; i < (n); i++) cin >> arr[i];
  int ans = 0;
  while (true) {
    sort(arr + 1, arr + n);
    bool won = true;
    for (int i = n - 1; i > 0; i--) {
      if (arr[0] <= arr[i]) {
        ans++;
        arr[0]++;
        arr[i]--;
        won = false;
        break;
      }
    }
    if (won) break;
  }
  cout << ans << endl;
  return 0;
}
