#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  scanf("%d", &n);
  int* array = (int*)malloc(sizeof(int) * n);
  for (int i = 0; i < n; i++) {
    scanf("%d", array + i);
  }
  int limak = array[0];
  sort(array + 1, array + n);
  int max = array[n - 1];
  int bribe = 0;
  if (max < limak) {
    printf("%d\n", bribe);
    return 0;
  }
  while (limak <= array[n - 1]) {
    limak++;
    bribe++;
    array[n - 1]--;
    sort(array + 1, array + n);
  }
  printf("%d\n", bribe);
  return 0;
}
