TLE error when tried to submit in CODECHEF

#include
#include
using namespace std;
#define ll long long
ll a[1000005];
ll cum[1000005];
ll fre[1000005];

int main() {
#ifndef ONLINE_JUDGE
freopen(“input.txt”, “r”, stdin);
freopen(“output.txt”, “w”, stdout);
#endif
int t;
cin >> t;
while (t > 0) {
memset(fre, 0, sizeof(fre));
int n;
cin >> n;
ll sum = 0;
for (int i = 0; i < n; i++) {
cin >> a[i];
sum += a[i];
cum[i] = sum;
sum %= n;
sum = (sum + n) % n;
fre[sum]++;
}
ll ans = 0;
ll var;
ll index;
for (int i = 0; i < n; i++) {
if ( i == 0) {
ll m = fre[i];
if (m > 0) {
var = 1;
index = i;
break;
}
} else {
ll m = fre[i];
if (m > 1) {
index = i;
var = 1;
break;
}
}

	}
	//cout << index << endl;
	for (int i = 0; i < n; i++) {
		if (cum[i] % n == index) {
			//cout << i << endl;
			if (index == 0) {
				ans = 1;
				
			} else {
				ans = i + 2;
				break;
			}
		}
	}
	cout << var << endl;
	cout << ans << endl;
	t--;

}

}
/*Inputs:
1
3
4 6 10

Outputs:
1
2*/

when i try to submit the above code in the codechef it is
showing TLE error but my code is running perfectly for the
given test cases , please say where is the error

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.