#include <bits/stdc++.h>
using namespace std;
set<int> s;
int main() {
  int n, i, j, a[102], c = 0;
  cin >> n;
  for (i = 0; i < n; i++) {
    cin >> a[i];
    if (i > 0) s.insert(a[i]);
  }
  set<int>::iterator it, l;
  while (1) {
    int mx_in = 1;
    for (i = 1; i < n; i++)
      if (a[mx_in] < a[i]) mx_in = i;
    int v = a[mx_in];
    if (a[0] > v) break;
    a[mx_in]--;
    a[0]++;
    c++;
  }
  cout << c;
  return 0;
}
