#include <bits/stdc++.h>
int n, cnt, mx, tar;
using namespace std;
struct node {
  int w, idx;
} a[110];
bool cmp(node c, node b) {
  if (c.w != b.w)
    return c.w > b.w;
  else
    return c.idx < b.idx;
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", &a[i].w), a[i].idx = i;
  sort(a + 1, a + 1 + n, cmp);
  if (a[1].idx == 1) {
    if (a[2].w == a[1].w)
      printf("1\n");
    else
      printf("0\n");
  } else {
    for (int i = 1; i <= n; i++)
      if (a[i].idx == 1) {
        tar = i;
        break;
      }
    mx = a[1].w;
    int k;
    while (a[tar].w <= mx) {
      for (int k = 1; a[k].w == mx && k != tar && a[tar].w <= mx; k++) {
        cnt++;
        a[k].w--;
        a[tar].w++;
      }
      mx = a[1].w;
    }
    printf("%d", cnt);
  }
}
