#include <bits/stdc++.h>
using namespace std;
const int MAX_INT = std::numeric_limits<int>::max();
const int MIN_INT = std::numeric_limits<int>::min();
const int INF = 1000000000;
const int NEG_INF = -1000000000;
int gcd(int a, int b) { return b == 0 ? a : gcd(b, a % b); }
int lcm(int a, int b) { return a * (b / gcd(a, b)); }
int N;
vector<int> candidates;
int main() {
  scanf("%d", &N);
  int v;
  int him;
  int max = 0;
  priority_queue<int> pq;
  for (int i = 0; i < N; i++) {
    scanf("%d", &v);
    if (i == 0)
      him = v;
    else {
      pq.push(v);
    }
  }
  int b = 0;
  while (true) {
    int a = pq.top();
    pq.pop();
    if (him > a) {
      break;
    }
    b++;
    a--;
    him++;
    pq.push(a);
  }
  printf("%d\n", b);
  return 0;
}
