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