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