#include <bits/stdc++.h>
using namespace std;
int main() {
  int a, maxn = -1, d = 0, z = 0;
  int arr[10000];
  cin >> a;
  for (int i = 0; i < a; i++) {
    cin >> arr[i];
    if (i != 0) maxn = max(maxn, arr[i]);
    if (maxn == arr[i]) z = i;
  }
  while (arr[0] <= maxn) {
    d++;
    arr[z] -= 1;
    arr[0] += 1;
    maxn = 0;
    for (int i = 1; i < a; i++) {
      maxn = max(maxn, arr[i]);
      if (maxn == arr[i]) z = i;
    }
  }
  cout << d;
}
