#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  int n;
  cin >> n;
  if (n == 1) {
    int k;
    cin >> k;
    cout << k;
    return 0;
  }
  vector<int> v;
  int frst;
  cin >> frst;
  for (int i = 1; i <= n - 1; i++) {
    int temp;
    cin >> temp;
    v.push_back(temp);
  }
  int c = 0;
  sort(v.begin(), v.end());
  while (v[v.size() - 1] >= frst) {
    frst++;
    v[v.size() - 1]--;
    sort(v.begin(), v.end());
    c++;
  }
  cout << c << '\n';
  return 0;
}
