#include <bits/stdc++.h>
using namespace std;
const int N = 1e3 + 10;
const int INF = 0x3f3f3f3f;
const int MOD = 1e9 + 7;
int a[N];
int n, x;
int main(void) {
  scanf("%d", &n);
  scanf("%d", &a[0]);
  n--;
  for (int i = 1; i <= n; ++i) scanf("%d", &a[i]);
  int ans = 0;
  while (true) {
    int mxi = 0;
    for (int i = 1; i <= n; ++i) {
      if (a[i] >= a[mxi]) mxi = i;
    }
    if (mxi == 0) break;
    ans++;
    a[0]++;
    a[mxi]--;
  }
  printf("%d\n", ans);
  return 0;
}
