Where i am geetig wrong in this code i think my logic is right but sum syntax error

#include
using namespace std;
int main() {
int n,i;
cin>>n;
int a[n];
int sum1=0;
int sum2=0;
for( i=1; i<=n; i++){
cin>>a[i];
}
for(int i=1; i<n; i++){

if(i%2==0){
	sum1=sum1+a[i];
	else{
		sum2=sum2+a[i];
	
	cout<<sum1<<endl;
	cout<<sum2<<endl;
	}

}
}
return 0;

}

the way you are approaching to this problem is incorrect…

Reference Code :