#include #include #include using namespace std; int main(){ int n,cnt=0; cin >> n; vector a(n); for(int i=0;i> a[i]; sort(a.begin(),a.end()); for(int i=1;i=a[i]){ a[i]++; cnt++; } } cout << cnt << endl; }