#include <bits/stdc++.h>
using namespace std;
void solve() {
  int n;
  cin >> n;
  int arr[n];
  for (int i = 0; i < n; i++) cin >> arr[i];
  int ans = 0;
  while (1) {
    int maxi = 0;
    for (int i = 0; i < n; i++) {
      if (arr[i] >= arr[maxi]) maxi = i;
    }
    if (maxi == 0) break;
    ans++;
    arr[0]++;
    arr[maxi]--;
  }
  cout << ans << "\n";
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int t;
  t = 1;
  while (t--) solve();
}
