#include <bits/stdc++.h>
using namespace std;
int INT_MAX_VAL = (int)0x3F3F3F3F;
int INT_MIN_VAL = (int)-0x3F3F3F3F;
long long LONG_MAX_VAL = (long long)0x3F3F3F3F3F3F3F3F;
long long LONG_MIN_VAL = (long long)-0x3F3F3F3F3F3F3F3F;
int main() {
  auto t_start = std::chrono::high_resolution_clock::now();
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  --n;
  int lim = 0;
  cin >> lim;
  vector<long long> vs(n);
  for (long long(i) = 0LL; (i) < (n); (i)++) cin >> vs[i];
  int res = 0;
  sort(vs.begin(), vs.end());
  while (lim <= vs.back()) {
    ++res;
    ++lim;
    --vs.back();
    sort(vs.begin(), vs.end());
  }
  cout << res << '\n';
  return 0;
}
