#include <bits/stdc++.h>
using namespace std;
priority_queue<int> q;
int main() {
  int n;
  scanf("%d", &n);
  int t;
  scanf("%d", &t);
  for (int i = 2; i <= n; i++) {
    int v;
    scanf("%d", &v);
    q.push(v);
  }
  int cnt = 0;
  while (q.top() >= t) {
    t++;
    cnt++;
    int v = q.top();
    q.pop();
    q.push(v - 1);
  }
  printf("%d\n", cnt);
  return 0;
}
