#include <bits/stdc++.h>
using namespace std;
int asd[105];
int main() {
  int n, zx, er, i, m, j, r, a, b, c;
  while (~scanf("%d", &n)) {
    zx = 0;
    er = 0;
    for (i = 0; i < n; i++) scanf("%d", &asd[i]);
    while (1) {
      sort(asd + 1, asd + n);
      if (asd[0] <= asd[n - 1]) {
        asd[0]++;
        asd[n - 1]--;
        er++;
      } else
        break;
    }
    printf("%d\n", er);
  }
  return 0;
}
