#include <bits/stdc++.h>
using namespace std;
template <typename T>
std::vector<std::vector<std::vector<T>>> make_3d_vector(long long z,
                                                        long long y,
                                                        long long x,
                                                        T value = T{}) {
  return std::vector<std::vector<std::vector<T>>>(
      z, std::vector<std::vector<T>>(y, std::vector<T>(x, value)));
}
template <typename T>
std::vector<std::vector<T>> make_2d_vector(long long z, long long y,
                                           T value = T{}) {
  return std::vector<std::vector<T>>(z, std::vector<T>(y, value));
}
template <typename T>
std::vector<T> make_1d_vector(long long z, T value = T{}) {
  return std::vector<T>(z, value);
}
void solve() {
  long long n;
  cin >> n;
  long long x;
  cin >> x;
  priority_queue<long long> pq;
  for (long long i = 0; i < n - 1; i++) {
    long long x;
    cin >> x;
    pq.push(x);
  }
  long long ct = 0;
  while (pq.top() >= x) {
    x++;
    long long r = pq.top();
    pq.pop();
    pq.push(r - 1);
    ct++;
  }
  cout << ct;
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  solve();
  cerr << "time taken : " << (float)clock() / CLOCKS_PER_SEC << " secs" << endl;
}
