#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, i, vote = 0;
  cin >> n;
  vector<int> v(n);
  for (i = 0; i < n; i++) cin >> v[i];
  sort(v.begin() + 1, v.end());
  while (v[0] <= v[n - 1]) {
    v[0]++;
    v[n - 1]--;
    vote++;
    sort(v.begin() + 1, v.end());
  }
  cout << vote;
}
