#include <bits/stdc++.h>
using namespace std;
inline int MAX(int a, int b) { return (a < b) ? b : a; }
inline int MIN(int a, int b) { return (a > b) ? b : a; }
int n;
int a[128] = {0};
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> n;
  for (int i = 0; i < n; ++i) cin >> a[i];
  bool first = false;
  int cnt = 0;
  sort(a + 1, a + n);
  while (!first) {
    if (a[0] <= a[n - 1]) {
      cnt++;
      a[0]++;
      a[n - 1]--;
    } else
      break;
    sort(a + 1, a + n);
  }
  cout << cnt << endl;
  return 0;
}
