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