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