#include <bits/stdc++.h>
using namespace std;
int n, l, a[100];
int main() {
  cin >> n;
  cin >> l;
  for (int i = 0; i < (n - 1); i++) {
    cin >> a[i];
  }
  sort(a, a + (n - 1));
  if (l > a[n - 2]) {
    cout << "0" << endl;
    exit(0);
  } else if (l == 1000 && a[n - 2] == 1000) {
    cout << "1" << endl;
    exit(0);
  }
  int k = 0;
  while (true) {
    if (l <= a[n - 2]) {
      l++;
      a[n - 2]--;
      k++;
    } else {
      break;
    }
    sort(a, a + (n - 1));
  }
  cout << k << endl;
  return 0;
}
