#include <bits/stdc++.h>
using namespace std;
int a[102];
int main() {
  int n;
  int ans = 0;
  int l = 0, i;
  a[0] = 0;
  cin >> n;
  for (i = 1; i <= n; i++) cin >> a[i];
  for (int j = 0;; j++) {
    for (i = 1; i <= n; i++) {
      if (a[i] >= a[l]) l = i;
    }
    if (l == 1)
      break;
    else {
      ans += 1;
      a[l] = a[l] - 1;
      a[1] = a[1] + 1;
    }
  }
  cout << ans << endl;
  return 0;
}
