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