#include <bits/stdc++.h>
using namespace std;
int a[110] = {0};
int main() {
  int n;
  scanf("%d", &n);
  int i;
  for (i = 0; i < n; i++) {
    scanf("%d", &a[i]);
  }
  int mx = 0, ans = 0, mxl;
  for (i = 1; i < n; i++) {
    if (a[i] > mx) {
      mx = a[i];
      mxl = i;
    }
  }
  while (a[0] <= mx) {
    ans++;
    a[0]++;
    a[mxl]--;
    mx = 0;
    for (i = 1; i < n; i++) {
      if (a[i] > mx) {
        mx = a[i];
        mxl = i;
      }
    }
  }
  printf("%d\n", ans);
  return 0;
}
