#include <bits/stdc++.h>
using namespace std;
int n, m, a[101], tmp;
int main() {
  cin >> n >> m;
  tmp = m;
  for (int i = 0; i < n - 1; i++) cin >> a[i];
  sort(a, a + n - 1);
  while (tmp <= a[n - 2]) {
    tmp++;
    a[n - 2]--;
    sort(a, a + n - 1);
  }
  cout << tmp - m;
}
