#include <bits/stdc++.h>
using namespace std;
int n, k, p, x, y;
vector<int> ans;
int main() {
  ios_base::sync_with_stdio(false);
  cin >> n;
  ans.resize(n);
  int ma = 0;
  int coun = 0;
  for (int i = 0; i < n; i++) {
    cin >> ans[i];
    ma = (ans[i] >= ans[ma] ? i : ma);
  }
  long long ansa = 0;
  while (ma != 0) {
    ma = 0;
    for (int i = 0; i < n; i++) {
      ma = (ans[i] >= ans[ma] ? i : ma);
    }
    if (ma > 0) {
      ++ansa;
      ans[ma]--;
      ans[0]++;
    }
  }
  cout << ansa << endl;
}
