#include <bits/stdc++.h>
using namespace std;
int n, lim, res, act;
int tab[1003];
bool win(int lim, int cheat) {
  for (int i = 1; i < n; i++) cheat -= max(0, tab[i] - lim + 1);
  return cheat >= 0;
}
int main() {
  cin >> n;
  cin >> lim;
  tab[0] = lim;
  for (int i = 1; i < n; ++i) {
    cin >> act;
    tab[i] = act;
  }
  for (int t = lim; t <= 1001; t++)
    if (win(t, t - lim)) {
      cout << t - lim << "\n";
      break;
    }
  return 0;
}
