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