#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  long long int a[n];
  int alpha = 0;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  sort(a + 1, a + n);
  while (a[0] <= a[n - 1]) {
    alpha++;
    a[n - 1] = a[n - 1] - 1;
    a[0]++;
    sort(a + 1, a + n);
  }
  cout << alpha << endl;
}
