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