One test case not passing

Hey, my code passes all test cases except for one test case, could you please help me figure out why that is happening?
Here is my code: https://onlinegdb.com/eC4bJZOmc

The 500,000th prime is 7,368,787 .

so size of array should be at least 7368788

Reference Code

Okay thanks for correcting it

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.