#include <bits/stdc++.h>
using namespace std;
int n;
int arr[110];
int main() {
  while (scanf("%d", &n) != EOF) {
    priority_queue<int> pq;
    for (int i = 0; i < n; i++) scanf("%d", &arr[i]);
    for (int i = 1; i < n; i++) {
      if (arr[i] >= arr[0]) pq.push(arr[i]);
    }
    int cnt = 0;
    while (!pq.empty()) {
      int cur = pq.top();
      pq.pop();
      if (cur < arr[0]) continue;
      cur--;
      arr[0]++;
      cnt++;
      if (cur >= arr[0]) pq.push(cur);
    }
    printf("%d\n", cnt);
  }
}
