#include <bits/stdc++.h>
using namespace std;
int main() {
  int x, v, arr[1000], c = 0;
  cin >> x >> v;
  for (int i = 0; i < x - 1; i++) {
    cin >> arr[i];
  }
  while (1) {
    sort(arr, arr + x - 1);
    if (v > arr[x - 2]) break;
    arr[x - 2]--;
    v++;
    c++;
  }
  cout << c;
  return 0;
}
