It is giving output for given test case but giving run error for other thestcases
@Namanjain123
It is mentioned in the problem constraints that
1<=n<=10^5
Your array size is 10^3. Increase your array size to accomodate the input data.
https://ide.codingblocks.com/s/161521 this is the modified code after changing int with long long but giving run error for two testcases