#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  scanf("%d", &n);
  int arr[n + 10];
  for (int i = 1; i <= n; i++) scanf("%d", &arr[i]);
  int ans = 0;
  int yes = 1;
  while (yes) {
    int mx = arr[1];
    int indx = -1;
    for (int i = 2; i <= n; i++) {
      if (arr[i] >= mx) {
        mx = arr[i];
        indx = i;
      }
    }
    if (mx >= arr[1] && indx != -1) {
      ans++;
      arr[1]++;
      arr[indx]--;
    } else
      yes = 0;
  }
  cout << ans << endl;
  return 0;
}
