#include <bits/stdc++.h>
using namespace std;
const int N = 50000;
long long int pows(long long int a, long long int n, long long int m) {
  long long int res = 1;
  while (n) {
    if (n % 2 != 0) {
      res = (res * a) % m;
      n--;
    } else {
      a = (a * a) % m;
      n = n / 2;
    }
  }
  return res % m;
}
bool check_prime(int n) {
  for (int i = 2; i < min(N, n); i++)
    if (n % i == 0) return 0;
  return 1;
}
int gcd(int a, int b) {
  if (b == 0)
    return a;
  else
    return gcd(b, a % b);
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n;
  cin >> n;
  priority_queue<int> pq;
  int a[101];
  int k = 0;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    if (i != 0) pq.push(a[i]);
  }
  k = a[0];
  int count = 0;
  while (1) {
    if (k > pq.top()) break;
    int p = pq.top();
    pq.pop();
    k++;
    p--;
    pq.push(p);
    count++;
  }
  cout << count << endl;
}
