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