#include <bits/stdc++.h>
using namespace std;
int main() {
  int arr[105];
  int n, i, res = 0, j, temp;
  cin >> n;
  for (i = 0; i < n; i++) cin >> arr[i];
  sort(arr + 1, arr + n);
  while (arr[0] <= arr[n - 1]) {
    res++;
    arr[0]++;
    arr[n - 1]--;
    temp = arr[n - 1];
    j = n - 2;
    while (arr[j] > temp && j > 0) {
      arr[j + 1] = arr[j];
      j--;
    }
    arr[j + 1] = temp;
  }
  cout << res;
  return 0;
}
