#include <bits/stdc++.h>
using namespace std;
int main() {
  vector<int> a;
  int n, x, aux, bear, count = 0;
  cin >> n;
  cin >> bear;
  for (int i = 0; i < n - 1; i++) {
    cin >> x;
    a.push_back(x);
  }
  sort(a.begin(), a.end());
  aux = a.size() - 1;
  while (bear <= a[aux]) {
    bear++;
    a[aux]--;
    count++;
    sort(a.begin(), a.end());
  }
  cout << count << endl;
  return 0;
}
