#include <bits/stdc++.h>
using namespace std;
struct sort_pred {
  bool operator()(const pair<int, int>& left, const pair<int, int>& right) {
    return left.second < right.second;
  }
};
struct convert {
  void operator()(char& c) { c = toupper((unsigned char)c); }
};
struct convertd {
  void operator()(char& c) { c = tolower((unsigned char)c); }
};
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }
vector<int> mark(1);
vector<set<int> > A;
const int MAX_N = 1;
int p[MAX_N];
int root_rank[MAX_N];
void make_set(int x) { p[x] = x; }
int find_root(int x) {
  if (p[x] == x) return x;
  return p[x] = find_root(p[x]);
}
void unite(int x, int y) {
  x = find_root(x);
  y = find_root(y);
  if (root_rank[x] < root_rank[y])
    p[x] = y;
  else {
    p[y] = x;
    if (root_rank[x] == root_rank[y]) {
      ++root_rank[y];
    }
  }
}
const int N = 1;
int lp[N + 1];
void DFS(vector<vector<int> > edges, int start) {
  stack<int> s;
  set<int> _set;
  s.push(start);
  while (!s.empty()) {
    int v = s.top();
    s.pop();
    vector<int>::iterator it;
    for (it = edges[v].begin(); it != edges[v].end(); ++it) {
      if (mark[*it] == 0) {
        cout << mark[*it] << "!!"
             << "\n";
        s.push(*it);
        _set.insert(*it);
        mark[*it] = 1;
      }
    }
  }
  if (_set.size()) A.push_back(_set);
}
vector<int> sieve(const int N) {
  vector<int> pr;
  for (int i = 2; i <= N; ++i) {
    if (lp[i] == 0) {
      lp[i] = i;
      pr.push_back(i);
    }
    for (int j = 0; j < (int)pr.size() && pr[j] <= lp[i] && i * pr[j] <= N; ++j)
      lp[i * pr[j]] = pr[j];
  }
  return pr;
}
int a[101];
int main() {
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  int cnt = 0;
  int max_ind = -1;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  while (max_ind != 0) {
    max_ind = 0;
    int maxx = 0;
    for (int i = 0; i < n; i++) {
      if (a[i] >= maxx) {
        max_ind = i;
        maxx = a[i];
      }
    }
    a[max_ind]--;
    a[0]++;
    cnt++;
  }
  cout << cnt - 1 << "\n";
  return 0;
}
