#include <stdarg.h>
#include <stdio.h>
#include <iostream>
#include <vector>
#include <string.h>
#include <algorithm>
#include <stdlib.h>
#include <memory>
#include <string.h>
#include <set>
#include <map>
#include <sstream>
#include <string>
using namespace std;
int main()
{
vector<int> vec;
int data = 0;
char str[100] = { 0 };
char *token = NULL;
string st;
gets(str);
token = strtok(str," ");
while(token != NULL)
{
vec.push_back(atoi(token));
token = strtok( NULL, " " );
}
/* 求最大子数组 */
int i = 0, j = 0;
int sum = 0, location = 0;
int begin = 0, end = 0;
for (i = 0; i < vec.size() - 1; i++)
{
sum = 0;
location = -1;
for (j = i; j < vec.size(); j++)
{
sum = sum + vec[j];
if (sum == 0)
{
location = j;
}
}
if (location != -1)
{
if ((location - i) > (end - begin))
{
begin = i;
end = location;
}
}
}
if ((begin == end && begin == 0))
{
}
else
{
for (i = begin; i <= end; i++)
{
if (i == begin)
{
cout << vec[i];
}
else
{
cout << " " << vec[i];
}
}
cout << endl;
}
return 0;
}