#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
const int N = 1e6 + 10;
const long long INF = 1e18;
const long double EPS = 1e-12;
priority_queue<int> pq;
int main() {
  int haha;
  int n;
  cin >> n;
  for (int i = (int)1; i < (int)n + 1; i++) {
    int x;
    cin >> x;
    if (i == 1)
      haha = x;
    else
      pq.push(x);
  }
  int ans = 0;
  while (haha <= pq.top()) {
    int val = pq.top();
    pq.pop();
    haha++;
    pq.push(val - 1);
    ans++;
  }
  cout << ans << endl;
  return 0;
}
