#include <bits/stdc++.h>
int scan() {
  int noRead = 0;
  char p = getchar();
  for (; p < 33;) {
    p = getchar();
  }
  while (p > 32) {
    noRead = (noRead << 3) + (noRead << 1) + (p - '0');
    p = getchar();
  }
  return noRead;
}
using namespace std;
int main(void) {
  int n = scan();
  int arr[101];
  int elem = scan();
  for (int i = 0; i < n - 1; ++i) arr[i] = scan();
  sort(arr, arr + n - 1, greater<int>());
  int ans = 0;
  bool condn = true;
  while (condn) {
    if (elem <= arr[0]) {
      elem++;
      ans++;
      arr[0]--;
    } else
      break;
    sort(arr, arr + n - 1, greater<int>());
  }
  printf("%d", ans);
  return 0;
}
