#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, cas, lm, arr[10000];
  cin >> n;
  cin >> lm;
  for (int i = 0; i < n - 1; i++) cin >> arr[i];
  sort(arr, arr + n - 1);
  int t = 0;
  while (arr[n - 2] >= lm) {
    arr[n - 2] = arr[n - 2] - 1;
    t++;
    sort(arr, arr + n - 1);
    lm += 1;
  }
  cout << t << endl;
  return 0;
}
