#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e3;
int a[maxn];
int main() {
  int n, ans = 0;
  cin >> n;
  for (int i = 0; i < n; i++) cin >> a[i];
  while (1) {
    int ind = 1, mx = -1;
    for (int i = 1; i < n; i++)
      if (mx < a[i]) {
        mx = a[i];
        ind = i;
      }
    if (a[0] > mx)
      return (cout << ans << endl ? 0 : 0);
    else {
      a[ind]--;
      a[0]++;
      ans++;
    }
  }
}
