#include using namespace std; int main(){ int n,sum[1002]={0},num=0,ans=0; string str; cin >> n; for(int i=0;i> str; int cnt = 0; for(int j=0;j=num){ ans = i; num = sum[i]; } } cout << ans << endl; }