#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int a[n], i, maxa;
  long int count = 0;
  for (i = 0; i < n; i++) {
    cin >> a[i];
  }
  maxa = *max_element(a + 1, a + n);
  while (a[0] <= maxa) {
    a[distance(a, max_element(a + 1, a + n))]--;
    a[0]++;
    count++;
    maxa = *max_element(a + 1, a + n);
  }
  cout << count;
  return 0;
}
