#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m, i, j, count = 0, lim;
  scanf("%d", &n);
  priority_queue<int, vector<int>, less<int> > q;
  int val, top = 0;
  for (i = 0; i < n; i++) {
    scanf("%d", &val);
    top = max(top, val);
    if (i == 0) {
      lim = val;
      continue;
    }
    q.push(val);
  }
  int ans = 0;
  while (lim <= q.top()) {
    int kk = q.top();
    q.pop();
    ans++;
    kk--;
    lim++;
    q.push(kk);
  }
  printf("%d\n", ans);
  return 0;
}
