/* * Solution for NCPC 2013 problem "Trees" by Jaap Eldering * Complexity: O(n log(n)) */ #include #include #include #include using namespace std; int main() { int n, res = 0; scanf("%d\n",&n); vector t(n); for(int i=0; i()); for(int i=0; ires ) res = i+2+t[i]; printf("%d\n",res); return 0; }