#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, i, value, ans = 0, j;
  cin >> n;
  int a[n - 1];
  cin >> value;
  for (i = 0; i < n - 1; i++) cin >> a[i];
  sort(a, a + n - 1, greater<int>());
  while (a[0] >= value) {
    value++;
    a[0]--;
    ans++;
    sort(a, a + n - 1, greater<int>());
  }
  cout << ans << endl;
  return 0;
}
