#include <bits/stdc++.h>
using namespace std;
int main() {
  int in, n, m, l = 0, k = 0;
  int akk[100];
  cin >> n >> l;
  for (int i = 0; i < n - 1; i++) {
    cin >> in;
    if (in >= l) {
      akk[k] = in;
      k++;
    }
  }
  k--;
  m = l;
  int t;
  for (int v = 0; v < k + 1; v++) {
    for (int p = 0; p < k + 1; p++) {
      if (akk[v] > akk[p]) {
        t = akk[v];
        akk[v] = akk[p];
        akk[p] = t;
      }
    }
  }
  if (k + 1 == 1) {
    while (l <= akk[k]) {
      l++;
      akk[k]--;
    }
    cout << l - m;
  } else {
    while (true) {
      int r;
      for (int v = 0; v < k + 1; v++) {
        for (int p = 0; p < k + 1; p++) {
          if (akk[v] > akk[p]) {
            r = akk[v];
            akk[v] = akk[p];
            akk[p] = r;
          }
        }
      }
      if (l > akk[0]) {
        cout << l - m << endl;
        break;
      } else {
        akk[0]--;
        l++;
      }
    }
  }
  return 0;
}
