#include <bits/stdc++.h>
using namespace std;
int main() {
  vector<int> s;
  int a, c, b = 0;
  cin >> a >> c;
  for (int i = 0; i < a - 1; i++) {
    int t;
    cin >> t;
    s.push_back(t);
  }
  sort(s.begin(), s.end());
  reverse(s.begin(), s.end());
  while (c <= s[0]) {
    c += 1;
    s[0]--;
    b++;
    sort(s.begin(), s.end());
    reverse(s.begin(), s.end());
  }
  cout << b;
}
