#include <stdio.h>

int main(void)
{
    unsigned int n;
    unsigned long   ans[100000] = { -1, };
    int	x = 2;
    int	xx[100000] = { -1, };

    if (fscanf(stdin, "%d", &n) != 1)
	return 0;
    for (int i = 0; i < n; i++) {
	long	a;
	if (fscanf(stdin, "%ld", &a) != 1)
	    return 0;
	if (a < 0) {
	    ans[x++] = ans[i%2];
	    xx[x] = i % 2;
	}

	ans[i%2] += a;

	for (int ix = 2; ix < x; ix++) {
	    if (ix % 2 == xx[ix])
		ans[ix] += a;
	}
    }

    unsigned long answer = 0;
    for (int i = 0; i < 100000; i++) {
	if (ans[i] == -1)
	    return 0;
	if (answer < ans[i])
	    answer = ans[i];
    }

    printf("%ld\n", answer);

    return 0;
}

/*
 * vim:smartindent:sw=4:sts=4:co=84:nu:wm=78:
 */
