#include <bits/stdc++.h>
using namespace std;
const int INF = 2 * 1e9 + 1e8;
int cmp(int A, int B) { return A > B; }
int main() {
  int n, a[100 + 10];
  int limak;
  cin >> n;
  cin >> limak;
  for (int i = 1; i < n; i++) cin >> a[i];
  sort(a + 1, a + n, cmp);
  int t = limak;
  while (t <= a[1]) {
    t++;
    a[1]--;
    sort(a + 1, a + n, cmp);
  }
  cout << t - limak << endl;
  return 0;
}
