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