#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, max = 0, c = 0, im;
  cin >> n;
  int v[n];
  for (int i = 0; i < n; i++) {
    cin >> v[i];
    if (v[i] > max && i > 0) {
      im = i;
      max = v[i];
    }
  }
  while (v[0] <= max) {
    v[0]++;
    c++;
    v[im]--;
    max = 0;
    for (int i = 1; i < n; i++) {
      if (v[i] > max) {
        im = i;
        max = v[i];
      }
    }
  }
  cout << c;
}
