#include <bits/stdc++.h>
using namespace std;
int n, l, acc;
priority_queue<int> que;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> n >> l;
  for (int i = 1; i < n; ++i) {
    int x;
    cin >> x;
    que.push(x);
  }
  acc = 0;
  bool b = 1;
  while (b) {
    int y = que.top();
    que.pop();
    if (l <= y) {
      ++l;
      --y;
      que.push(y);
      ++acc;
    } else
      b = 0;
  }
  cout << acc << endl;
  return 0;
}
