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