#include <bits/stdc++.h>
using namespace std;
long long n, a[100001], m = 0, s = 0, ans = 0;
priority_queue<int> k;
int main() {
  cin >> n;
  for (long long i = 1; i <= n; i++) {
    cin >> a[i];
    if (i > 1) k.push(a[i]);
  }
  while (a[1] <= k.top()) {
    a[1]++;
    m = k.top();
    k.pop();
    k.push(m - 1);
    ans++;
  }
  cout << ans;
  return 0;
}
