#include <bits/stdc++.h>
using namespace std;
int a[100];
int readint() {
  char c = getchar();
  while (c < '0' || c > '9') c = getchar();
  int ret = 0;
  while (c >= '0' && c <= '9') {
    ret = 10 * ret + c - 48;
    c = getchar();
  }
  return ret;
}
int main() {
  int n = readint();
  int x = readint();
  for (int i = 0; i < n - 1; i++) a[i] = readint();
  sort(a, a + n - 1);
  int c = 0;
  while (x <= a[n - 2]) {
    x++;
    c++;
    a[n - 2]--;
    sort(a, a + n - 1);
  }
  printf("%d\n", c);
  return 0;
}
