#include <bits/stdc++.h>
using namespace std;
int main(int argc, char *argv[]) {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  int N;
  cin >> N;
  int limaksVotes;
  cin >> limaksVotes;
  priority_queue<int> pq;
  for (int i = 1; i < N; ++i) {
    int a;
    cin >> a;
    pq.push(a);
  }
  int bribes = 0;
  while (pq.top() >= limaksVotes) {
    int votes = pq.top();
    pq.pop();
    --votes;
    ++bribes;
    ++limaksVotes;
    pq.push(votes);
  }
  cout << bribes << endl;
  return 0;
}
