#include <bits/stdc++.h>   using namespace std;   int main() {     int a;     cin >> a;     int max = 0;     vector<int> b;     int x;     for (int i = 0; i < a; i++) {       cin >> x;       b.push_back(x);     }     sort(b.begin() + 1, b.end());     int count = 0;     if (b[0] > b[b.size() - 1]) {       cout <<  0 ;     } else {       while (1) {         b[b.size() - 1]--;         count++;         b[0] = b[0] + 1;         sort(b.begin() + 1, b.end());         if (b[0] > b[b.size() - 1]) {           cout << count;           break;         }       }     }     printf(  n );     return 0;   }   