#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int a[100009];
  int mx = 0, ix = 1;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    if (i && a[i] > mx) mx = a[i], ix = i;
  }
  int ans = 0;
  while (true) {
    if (a[0] > mx) break;
    a[0]++;
    ans++;
    a[ix]--;
    mx = a[ix];
    for (int i = 1; i < n; i++) {
      if (mx < a[i]) mx = a[i], ix = i;
    }
  }
  cout << ans;
}
