#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  scanf("%d", &n);
  int arr[n + 1];
  for (int i = 0; i < n; i++) {
    scanf("%d", &arr[i]);
  }
  int prev = arr[0];
  while (true) {
    int maxi = arr[1], loc = 1;
    for (int i = 1; i < n; i++) {
      if (arr[i] > maxi) {
        maxi = arr[i];
        loc = i;
      }
    }
    if (arr[0] > arr[loc]) break;
    arr[0]++;
    arr[loc]--;
  }
  cout << arr[0] - prev;
  return 0;
}
