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