#include <string>
#include <vector>
using namespace std;
int solution(vector<int> cookie) {
int answer = 0;
int size=cookie.size();
for(int i=0;i<size;i++)
{
int start=i;
int end=i+1;
int left=cookie[start];
int right=cookie[end];
while(start>=0&&end<size)
{
if(left==right)
{
if(left>answer)
answer=left;
if(start==0||end==size-1)
break;
else{
left+=cookie[--start];
right+=cookie[++end];
}
}
else if(right>left)
{
start--;
if(start>=0)
left+=cookie[start];
}
else
{
end++;
if(end<size)
right+=cookie[end];
}
}
}
return answer;
}