#include <bits/stdc++.h>
using namespace std;
std::set<pair<int, int> > v;
int main() {
  int n;
  int k;
  int tmp;
  cin >> n >> k;
  v.insert(make_pair(k, 1));
  for (int i = 1; i < n; ++i) {
    cin >> tmp;
    v.insert(make_pair(tmp, i + 1));
  }
  int sol = 0;
  pair<int, int> tmp2;
  auto it = v.end();
  auto it2 = v.end();
  it--;
  while (it->second != 1) {
    tmp = v.erase(make_pair(k + sol, 1));
    sol++;
    it2 = v.end();
    it2--;
    tmp2 = *(it2);
    v.erase(it2);
    v.insert(make_pair(tmp2.first - 1, tmp2.second));
    v.insert(make_pair(k + sol, 1));
    it = v.end();
    it--;
  }
  cout << sol << endl;
}
