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