#include <bits/stdc++.h>
using namespace std;
int a[105];
int main() {
  int sum = 0;
  priority_queue<int, vector<int>, less<int>> que;
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  for (int i = 1; i < n; i++) {
    que.push(a[i]);
  }
  int m;
  int m1 = a[0];
  while (m1 <= que.top()) {
    m = que.top();
    que.pop();
    m1 += 1;
    m = m - 1;
    que.push(m);
    sum += 1;
  }
  cout << sum << endl;
  return 0;
}
