#include <bits/stdc++.h>
using namespace std;
int a[105];
int n;
bool check(int* a, int i) {
  int total = a[1] + i;
  for (int j = 2; j < n + 1; j++) {
    if (total > a[j]) return true;
    i -= (a[j] - total) + 1;
    if (i < 0) return false;
  }
  return true;
}
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
  }
  sort(a + 2, a + n + 1, greater<int>());
  cout << endl;
  cout << endl;
  if (a[1] > a[2]) {
    cout << 0 << endl;
    return 0;
  }
  int i = (a[2] - a[1]) / 2 + 1;
  while (1) {
    if (check(a, i)) {
      cout << i << endl;
      break;
    }
    i++;
  }
}
