#include <bits/stdc++.h>
using namespace std;
int n, a[1001], mx, mxc, coun;
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    if (mx <= a[i]) {
      mx = a[i];
      mxc = i;
    }
  }
  if (mxc == 1)
    cout << 0;
  else {
    while (true) {
      mx = 0;
      for (int i = 2; i <= n; i++) {
        if (mx < a[i]) {
          mx = a[i];
          mxc = i;
        }
      }
      if (mx < a[1])
        break;
      else {
        a[mxc]--;
        a[1]++;
        coun++;
      }
    }
    cout << coun;
  }
  return 0;
}
