#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  int n;
  cin >> n;
  long long a[n];
  long long my;
  cin >> my;
  long long MAX = 0;
  for (int i = 1; i < n; i++) {
    cin >> a[i];
    MAX = max(MAX, a[i]);
  }
  int posmax;
  long long ans = 0;
  while (true) {
    MAX = 0;
    for (int i = 1; i < n; i++) {
      if (a[i] > MAX) {
        MAX = a[i];
        posmax = i;
      }
    }
    if (my > MAX) {
      break;
    }
    a[posmax]--;
    my++;
    MAX--;
    ans++;
  }
  cout << ans << endl;
  return 0;
}
