#include <bits/stdc++.h>
using namespace std;
struct myp {
  int x;
  int y;
};
bool sorts(myp &f, myp &s) { return f.x > s.x; };
int dx[4] = {-1, 0, 0, 1};
int dy[4] = {0, 1, -1, 0};
bool checkvisited[2007][2007];
bool check[10000];
bool visited[500];
int mymax[105];
int count1[100000];
long long gcd(long long a, long long b) {
  if (b == 0)
    return a;
  else
    return gcd(b, a % b);
}
bool isok(int n, int x, int y) {
  if (x >= 0 && x < n && y >= 0 && y < n) return true;
  return false;
}
void dos(int *a, int &tmp) {
  while (a[tmp] != tmp) {
    check[a[tmp]] = true;
    tmp = a[tmp];
  }
}
int main() {
  int n;
  cin >> n;
  int *a;
  a = new int[n];
  int num = 0;
  int max = 0;
  int index = 0;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    if (a[i] >= max) {
      max = a[i];
      index = i;
    }
  }
  if (index == 0) {
    cout << "0";
    return 0;
  } else {
    int count = 0;
    while (true) {
      int max = 0;
      int index = 0;
      for (int i = 0; i < n; i++) {
        if (a[i] >= max) {
          max = a[i];
          index = i;
        }
      }
      if (index == 0) {
        cout << count;
        return 0;
      } else {
        a[0] += 1;
        a[index]--;
        count += 1;
      }
    }
  }
}
