import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.StringTokenizer;

public class fish_sm_greed {
	int n;
	int[] a;
	boolean[] u;
	int[] res = new int[2];
	int[][] p = new int[2][2];

	void makeInit(int pl, int step) {
		int maxi = -1;
		for (int i = 0; i < n; i++) {
			if (!u[i] && (maxi == -1 || a[maxi] < a[i])) {
				maxi = i;
			}
		}
		u[maxi] = true;
		p[pl][step] = maxi;
		res[pl] += a[maxi];
	}

	void makeMove(int pl) {
		int besti = -1;
		int bestj = -1;
		for (int i = 0; i < 2; i++) {
			for (int dir = -1; dir <= 1; dir += 2) {
				for (int j = p[pl][i] + dir; j >= 0 && j < n; j += dir) {
					if (u[j])
						break;
					if (besti == -1 || a[bestj] < a[j]) {
						besti = i;
						bestj = j;
					}
				}
			}
		}
		if (besti == -1)
			return;
		res[pl] += a[bestj];
		p[pl][besti] = bestj;
		u[bestj] = true;
	}

	void solve() {
		n = nextInt();
		a = new int[n];
		for (int i = 0; i < a.length; i++) {
			a[i] = nextInt();
		}
		u = new boolean[n];
		makeInit(0, 0);
		makeInit(1, 0);
		makeInit(0, 1);
		makeInit(1, 1);
		for (int i = 0; i < 2 * n; i++) {
			makeMove(0);
			makeMove(1);
		}
		out.println(res[0] - res[1]);
		System.out.println(res[0] - res[1]);
	}

	BufferedReader br;
	StringTokenizer st;
	PrintWriter out;

	public void run() {
		try {
			String filename = "fish";
			br = new BufferedReader(new FileReader(filename + ".in"));
			out = new PrintWriter(filename + ".out");
			solve();
			out.close();
		} catch (IOException e) {
			e.printStackTrace();
			System.exit(1);
		}
	}

	String nextToken() {
		try {
			while (st == null || !st.hasMoreTokens()) {
				String s = br.readLine();
				if (s == null) {
					return null;
				}
				st = new StringTokenizer(s);
			}
			return st.nextToken();
		} catch (IOException e) {
			throw new RuntimeException();
		}
	}

	int nextInt() {
		return Integer.parseInt(nextToken());
	}

	long nextLong() {
		return Integer.parseInt(nextToken());
	}

	public static void main(String[] args) {
		long time = System.currentTimeMillis();
		new fish_sm_greed().run();
		System.err.println(System.currentTimeMillis() - time);
	}
}
