#include <bits/stdc++.h>
using namespace std;

int main() {
	vector <int> arr={3,6,2,3,5};
	int n=arr.size();
	int x=0,y=0,turn=0,reverse=0,i=0,j=n-1;
	while(i<=j){
	if(reverse==0){
		if(arr[i]%2==0){
			reverse=1;
		}
		if(turn%2==0){
			x+=arr[i];
			
		}else{
			y+=arr[i];
		}
		i++;
	}else{
		if(arr[j]%2==0){
			reverse=0;
		}
		if(turn%2==0){
			x+=arr[j];
		}else{
			y+=arr[j];
		}
		
		j--;
	}
	cout<<turn<<"  "<<x<<"  "<<y<<"   "<<reverse<<endl;
		turn++;
		
	}
		
	
		
	
	cout<<x<<endl;
	cout<<y;
	return 0;
}