#include <bits/stdc++.h>
using namespace std;
priority_queue<int> x;
int main() {
  ios_base::sync_with_stdio(0);
  int n;
  cin >> n;
  int s;
  cin >> s;
  int q;
  for (int i = 1; i < n; ++i) {
    cin >> q;
    x.push(q);
  }
  int licz = 0;
  while (s <= x.top()) {
    q = x.top();
    x.pop();
    --q;
    ++s;
    x.push(q);
    ++licz;
  }
  cout << licz << "\n";
}
