#include <bits/stdc++.h>
using namespace std;
int arr[210];
int main() {
  int n, i, max_ = 0, index, ans = 0;
  scanf("%d", &n);
  for (i = 0; i < n; ++i) {
    scanf("%d", &arr[i]);
    if (arr[i] >= max_) {
      max_ = max(max_, arr[i]);
      index = i;
    }
  }
  while (index != 0) {
    ++arr[0];
    --arr[index];
    ++ans;
    max_ = 0;
    for (i = 0; i < n; ++i) {
      if (arr[i] >= max_) {
        max_ = max(max_, arr[i]);
        index = i;
      }
    }
  }
  printf("%d\n", ans);
  return 0;
}
