#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  int n;
  int a[1001];
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  int ans = 0;
  while (true) {
    int pos = 0;
    for (int i = 0; i < n; i++) {
      if (a[i] >= a[pos]) pos = i;
    }
    if (pos != 0) {
      a[pos]--;
      a[0]++;
      ans++;
    } else {
      break;
    }
  }
  cout << ans;
  return 0;
}
