#include <bits/stdc++.h>
using namespace std;
vector<int> x;
int main() {
  int n, k, t, c = 0;
  cin >> n;
  cin >> k;
  x.resize(n - 1);
  for (int i = 0; i < n - 1; i++) {
    cin >> t;
    x.push_back(t);
  }
  sort(x.rbegin(), x.rend());
  while (x[0] >= k) {
    c++;
    k++;
    x[0]--;
    sort(x.rbegin(), x.rend());
  }
  cout << c << endl;
  return 0;
}
