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