import java.io.*;
import java.util.*;

public class fish_mb {
    static int[] data;
    static int n;
    static boolean[] succeeded = new boolean[2];
    static boolean[] used;
    static InitialEntry LEFT;
    static InitialEntry RIGHT;
    static InitialEntry[] entries;
    static int[] psums;

    static class InitialEntry implements Comparable<InitialEntry> {
        final int position;
        final int player;
        int activation;

        InitialEntry(int position, int player, int activation) {
            this.position = position;
            this.player = player;
            this.activation = activation;
        }

        public int compareTo(InitialEntry that) {
            return position - that.position;
        }
    }

    static int play(int player, int function) {
        if (!succeeded[0] && !succeeded[1]) {
            return function;
        }

        int rv = Integer.MIN_VALUE;

        succeeded[player] = false;

        for (int i = 1; i + 1 < entries.length; ++i) {
            InitialEntry curr = entries[i];
            InitialEntry next = entries[i + 1];
            InitialEntry prev = entries[i - 1];
            if (curr.player == player && curr.activation == 0) {
                if (curr.position + 1 < next.position && next.activation >= 0) {
                    curr.activation = 1;
                    int nf = function + psums[i];
                    succeeded[player] = true;
                    rv = Math.max(rv, -play(1 - player, -nf));
                }
                if (curr.position - 1 > prev.position && prev.activation <= 0) {
                    curr.activation = -1;
                    int nf = function + psums[i - 1];
                    succeeded[player] = true;
                    rv = Math.max(rv, -play(1 - player, -nf));
                }
                curr.activation = 0;
            }
        }

        if (rv == Integer.MIN_VALUE) {
            rv = Math.max(rv, -play(1 - player, -function));
        }

        return rv;
    }

    static int setup(InitialEntry[] localEntries, int depth, int player, int function) {
        if (depth == localEntries.length) {
            if (entries == null) {
                entries = new InitialEntry[localEntries.length + 2];
            }
            System.arraycopy(localEntries, 0, entries, 0, localEntries.length);
            entries[entries.length - 2] = LEFT;
            entries[entries.length - 1] = RIGHT;
            Arrays.sort(entries);
            Arrays.fill(succeeded, true);
            if (psums == null) {
                psums = new int[entries.length - 1];
            } else {
                Arrays.fill(psums, 0);
            }
            for (int i = 0; i < psums.length; ++i) {
                for (int j = entries[i].position + 1; j < entries[i + 1].position; ++j) {
                    psums[i] += data[j];
                }
            }
            return play(player, function);
        } else {
            int rv = Integer.MIN_VALUE;
            for (int pos = 0; pos < n; ++pos) {
                if (!used[pos]) {
                    used[pos] = true;
                    localEntries[depth] = new InitialEntry(pos, player, 0);
                    rv = Math.max(rv, -setup(localEntries, depth + 1, 1 - player, -function - data[pos]));
                    used[pos] = false;
                }
            }
            return rv;
        }
    }

    public static void main(String[] args) throws IOException {
        Scanner in = new Scanner(new File("fish.in"));
        n = in.nextInt();
        data = new int[n];
        for (int i = 0; i < n; ++i) {
            data[i] = in.nextInt();
        }
        in.close();

        used = new boolean[n];

        LEFT = new InitialEntry(-1, 0, -1);
        RIGHT = new InitialEntry(n, 0, 1);

        PrintWriter out = new PrintWriter("fish.out");
        out.println(setup(new InitialEntry[4], 0, 0, 0));
        out.close();
    }
}
