Please explain why this code is not passing test cases

On dry run its giving correct answer

Save your code on ide.codingblocks.com and then share its link.

this is the link and the code is not passing 1 test case:https://ide.codingblocks.com/

You are checking primes upto 10^5 but it is mentioned in the input format that answer can be upto 10^6, so check and store prime numbers upto 10^6.

now its not even passing a single test case

You have not shared the link of your updated code. The above link has not code in it.
Refer this implementation https://ide.codingblocks.com/s/257455
and then check with your code.

ok,i got the code and it passed all the test cases,but is’nt there any alternative of declaring an array globally,why can’t we declare it inside main()

Inside main if you declare the array,then its maxm size limit is of order 10^5.
But globally it increases to 10^7.

Mark the doubt as resolved if you are satisfied with the answer.

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.