#include <iostream>
#include <vector>

int main() {
	std::ios_base::sync_with_stdio(false);
	std::cin.tie(nullptr);
	int n;
	std::cin >> n;
	std::vector<int> w(n);
	for (int i = 0; i < n; i++) {
		std::cin >> w[i];
		if (i % 2)
			w[i] = -w[i];
	}
	long long min = 0, min_sum = 0;
	long long max = 0, max_sum = 0;
	for (int i = 0; i < n; i++) {
		min_sum += w[i];
		if (min_sum < min)
			min = min_sum;
		if (min_sum > 0)
			min_sum = 0;
		max_sum += w[i];
		if (max_sum > max)
			max = max_sum;
		if (max_sum < 0)
			max_sum = 0;
	}
	std::cout << max << '\n' << -min << '\n';
	return 0;
}
