#include<iostream>
#include<algorithm>
#include<vector>
#include<set>
#include<string>


int main() {
	int n;
	std::cin >> n;
	long long ans = 0;
	long long a;
	for (int i = 0; i < n; i++) {
		std::cin >> a;
		if (a != 0 || ans != 0) ans = std::max(ans + a, std::max(ans - a, std::max(ans / a, std::max(ans * a,std::max(-ans*a,-ans/a)))));
		else ans = std::max(ans + a, std::max(ans - a, ans * a));
		std::cout << ans << std::endl;
	}
	std::cout << ans << std::endl;
}