#include <bits/stdc++.h>
using namespace std;
struct code {
  int x, y;
};
int res, k;
string s;
int gcd(int a, int b) {
  while (b) {
    a %= b;
    swap(a, b);
  }
  return a;
}
int a[100001], ans;
int main() {
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
  }
  int ans = 0;
  while (1) {
    int ok = 0;
    for (int i = 2; i <= n; i++) {
      if (a[1] > a[i]) ok++;
    }
    if (ok == n - 1) break;
    int q = -1e9, id = 0;
    for (int j = 2; j <= n; j++) {
      if (q < a[j]) {
        q = a[j];
        id = j;
      }
    }
    a[1]++;
    a[id]--;
    ans++;
  }
  cout << ans;
}
