#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, i;
  scanf("%d", &n);
  int my, a[100002];
  scanf("%d", &my);
  for (i = 0; i < n - 1; i++) scanf("%d", &a[i]);
  sort(a, a + (n - 1));
  int ans = 0;
  while (1) {
    if (my > a[n - 2]) break;
    ans++;
    a[n - 2]--;
    my++;
    sort(a, a + (n - 1));
  }
  printf("%d", ans);
  return 0;
}
