#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, countx = 0;
  scanf("%d", &n);
  vector<int> d(n);
  for (int i = 0; i < n; i++) scanf("%d", &d[i]);
  while (true) {
    vector<int>::iterator it = max_element(d.begin() + 1, d.end());
    if (*it < d[0])
      break;
    else
      d[it - d.begin()]--, d[0]++, countx++;
  }
  printf("%d", countx);
}
