# PROBLEM LINK:

Practice

Contest: Division 1

Contest: Division 2

Contest: Division 3

* Author:* Daanish Mahajan

*Anay Karnik*

**Tester:***Mohan Abhyas*

**Editorialist:**# DIFFICULTY:

Cakewalk

# PREREQUISITES:

None

# PROBLEM:

You are given an integer N. Consider the sequence containing the integers 1, 2, \ldots, N in increasing order (each exactly once). Find the maximum length of its contiguous subsequence with an even sum.

# EXPLANATION:

\sum_{k=1}^{k=n} k = n*(n+1)/2

Take whole sequence if above sum is even else leave out 1 to make sum odd

# TIME COMPLEXITY:

\mathcal{O}(1) per testcase.

# SOLUTIONS:

[details = âEditorialâs Solutionâ]

```
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define forn(i,e) for(ll i = 0; i < e; i++)
void solve()
{
ll n;
cin>>n;
ll sum = (n*(n+1))/2;
if(sum%2)
{
cout<<n-1<<endl;
}
else
{
cout<<n<<endl;
}
}
int main()
{
ll t=1;
cin >> t;
forn(i,t) {
solve();
}
return 0;
}
```