#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, i, v, arr[101], c = 0;
  cin >> n >> v;
  for (i = 0; i < n - 1; i++) cin >> arr[i];
  while (v <= *max_element(arr, arr + n - 1)) {
    sort(arr, arr + n - 1);
    arr[n - 2]--;
    c++;
    v++;
  }
  cout << c << endl;
}
