#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int tab[100];
  for (int i = 0; i < n; i++) {
    cin >> tab[i];
    cout << " ";
  }
  int nb = 0;
  int x = 1;
  int l = 0;
  while (x == 1) {
    l = 1;
    int max;
    max = tab[1];
    for (int i = 2; i < n; i++) {
      if (tab[i] > max) {
        max = tab[i];
        l = i;
      }
    }
    if (tab[0] <= max) {
      tab[0] += 1;
      tab[l] -= 1;
      nb++;
      x = 1;
    } else {
      x = 0;
    }
  }
  cout << nb;
  return 0;
}
