Please help me to solve the question

you have not taken input (the array)
first take input correctly
like this

int a[1000]; 
    int b[1000]; 
    cin>>f; 
    for(int i=0;i<f;i++)cin>>a[i];
    cin>>s;  
    for(int i=0;i<f;i++)cin>>a[i];

now try to code and if you have any problem feel free to ask

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.