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