Learning course: Level up from 1* to 2*

Problem Link: CodeChef: Practical coding for everyone

### Feedback

include <bits/stdc++.h>

using namespace std;

int main() {

int t;

cin >> t;

```
while (t--) {
long long int n;
cin >> n;
long long int sum = (n * (n + 1)) / 2;
if (sum % 2 == 0) {
cout << n << endl;
} else {
for (int i = n; i >= 1; i--) {
sum -= i;
if (sum % 2 == 0) {
cout << n - 1 << endl;
break;
}
}
}
}
return 0;
```

}

It is for problem statement maximum length subarray. I believe last print statement should be n-i but it is giving wrong answer and correct answer is with n-1 pls explain why it is like this. I dry ran the code and am getting wrong output