#include int main(int argc, char **argv) { int maxsofar = 0; int maxendinghere = 0; int x; while (scanf("%d", &x) == 1) { maxendinghere += x; if (maxendinghere < 0) maxendinghere = 0; if (maxendinghere > maxsofar) maxsofar = maxendinghere; } printf("%d\n", maxsofar); }