#include <bits/stdc++.h>
using namespace std;
int n, bear, ans, a, aux, votes[128];
priority_queue<int> q;
int Solution() {
  int ans = 0;
  while (bear <= q.top()) {
    aux = q.top();
    if (bear <= aux) {
      bear++;
      aux--;
      q.pop();
      q.push(aux);
      ans++;
    }
  }
  return ans;
}
int main() {
  scanf("%d", &n);
  scanf("%d", &bear);
  for (int i = 0; i < n - 1; ++i) {
    scanf("%d", &a);
    q.push(a);
  }
  ans = Solution();
  printf("%d\n", ans);
  return 0;
}
