Testcase 1 not passing (timelimit)

code:

Yash , firstly use long long int ar[10000000];
and also try to follow this youtube lecture if your code still shows TLE,