#include #include #include #include #include #include #include #include #include #include #include #include using namespace std; using ll = long long; int main(){ int N, ans=0, now=0; cin >> N; vector R(N-1); for (int i=0; i> R[i]; R[i]--; } for (int i=1; i