#include <bits/stdc++.h>
using namespace std;
int s[505];
int n;
bool cmp(int a, int b) { return a > b; }
int main() {
  while (scanf("%d", &n) != EOF) {
    int s1;
    int flag = 0;
    cin >> s1;
    int ans = 0;
    for (int i = 1; i < n; i++) {
      cin >> s[i];
      s[i] -= s1;
    }
    sort(s + 1, s + n, cmp);
    int t;
    while (!flag) {
      flag = 1;
      for (int i = 1; i < n; i++) {
        if (s[i] >= 0) {
          flag = 0;
          break;
        }
      }
      if (flag == 0) {
        t = 1;
        for (int i = 1; i < n; i++)
          if (s[i] > s[t]) t = i;
        s[t]--;
        for (int i = 1; i < n; i++) s[i]--;
        ans++;
      }
    }
    cout << ans << endl;
  }
  return 0;
}
