Where is the mistake in this code?

#include<bits/stdc++.h>
using namespace std;
int main() {
int t; cin >> t;
// cout << "Test Cases " << t << endl;
while(t–){
int n; cin >> n;
int a[n]; for(int i = 0; i < n; i++) cin >> a[i];
int maxi = 0, sum = 0;
for(int i = 0; i < n; i++){
sum += a[i];
sum = max(sum, 0), maxi = max(sum, maxi);
}
cout << maxi;
}
return 0;
}

Use endl after you print the maximum sum.