#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, a[100], i, j, c = 0, t, in;
  cin >> n;
  for (i = 0; i < n; i++) cin >> a[i];
  while (1) {
    t = a[0];
    in = 0;
    for (i = 1; i < n; i++) {
      if (a[i] >= t) {
        t = a[i];
        in = i;
      }
    }
    if (in == 0) break;
    a[in]--;
    a[0]++;
    c++;
  }
  cout << c;
}
