I am getting WA for the problem MNMX. Could any one please tell me where I am going wrong ?Here is my code:

```
int main() {
int t;
cin>>t;
while ( t-- ) {
int n;
cin>>n;
vector<int> a,b;
int sum = 0;
for ( int i = 0 ; i < n; i++ ) {
int tmp;
cin>>tmp;
a.push_back(tmp);
}
while ( true ) {
int len = a.size();
b.clear();
if ( len <= 1 ) {
break;
}
for ( int i = 0; i < len-1 ; i+=2 ) {
if ( a[i] <= a[i+1]) {
sum += a[i];
b.push_back(a[i]);
}
else {
sum += a[i+1];
b.push_back(a[i+1]);
}
}
if ( len % 2 != 0 ) {
b.push_back(a[len-1]);
}
a.clear();
a = b;
}
cout<<sum<<endl;
}
return 0;
}
```