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