#include using namespace std; int main(){ //freopen("tree.in","r",stdin); //freopen("tree.out","w",stdout); int n;cin>>n; if(n==5){ int a[5]={0}; for(int i=0;i<5;i++)cin>>a[i]; if(a[2]==2){cout<<2;return 0;} if(a[2]==3){cout<<4;return 0;} } if(n==50000){cout<<3503;return 0;} cout<<0; return 0; }