#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, l;
  cin >> n >> l;
  priority_queue<int> pq;
  int v;
  for (int i = 1; i < n; i++) {
    cin >> v;
    pq.push(v);
  }
  int ans = 0;
  while (!pq.empty()) {
    int cur = pq.top();
    if (cur < l) break;
    pq.pop();
    l++;
    ans++;
    cur--;
    pq.push(cur);
  }
  cout << ans;
}
