#include <bits/stdc++.h>
using namespace std;
const int N = 110;
int main() {
  int n;
  cin >> n;
  int a[N] = {0};
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  int maxi = -1, pos = -1, candy = 0;
  for (;;) {
    for (int i = 1; i < n; i++) {
      if (a[0] <= a[i] && a[i] > maxi) {
        maxi = a[i];
        pos = i;
      }
    }
    if (maxi == -1) break;
    a[0]++;
    a[pos]--;
    candy++;
    maxi = -1;
    pos = -1;
  }
  cout << candy << endl;
  return 0;
}
