#include <bits/stdc++.h>
using namespace std;
int lim, size, ans;
int others[1000];
int main() {
  scanf("%d", &size);
  size--;
  scanf("%d", &lim);
  ans = lim;
  for (int i = 0; i < size; i++) {
    scanf("%d", &others[i]);
  }
  sort(others, others + size, greater<int>());
  while (lim <= others[0]) {
    lim++;
    others[0]--;
    sort(others, others + size, greater<int>());
  }
  printf("%d\n", lim - ans);
  return 0;
}
