import java.io.*;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.StringTokenizer;

public class Main {

    static class Task {

        private int n;
        private long[] arr;
        private Map<Long, Long> memo;

        private long getAns(int from) {
            long sum1 = 0;
            long sum2 = 0;
            for (int i = from; i < n; i+=2) {
                sum1 += arr[i];
            }

            for (int i = from + 1; i < n; i+=2) {
                sum2 += arr[i];
            }

            return Math.max(sum1, sum2);
        }

        private long dp(int idx, int k) {
            if (k == 0) {
                return 0;
            }

            if (idx >= n) {
                return Long.MIN_VALUE;
            }

            if (n - idx + 1 < 2 * k) {
                return Long.MIN_VALUE;
            }

            long key = (long) k * n + idx;
            if (memo.containsKey(key)) {
                return memo.get(key);
            }

//            if ((n - idx) % 2 == 0) {
//                return getAns(idx);
//            }

            long chooseRes = arr[idx] + dp(idx + 2, k - 1);
            long nonChooseRes = dp(idx + 1, k);
            long res = Math.max(chooseRes, nonChooseRes);
            memo.put(key, res);
            return res;
        }

        public void solve(int testNumber, InputReader in, PrintWriter out) {
            n = in.nextInt();
            arr = new long[n];
            for (int i = 0; i < n; i++) {
                arr[i] = in.nextLong();
            }

//            memo = new Long[n + 1];
            memo = new HashMap<>();
            long ans = dp(0, n / 2);
            out.println(ans);
//            if (n % 2 == 0) {
//                long sum1 = 0;
//                long sum2 = 0;
//                for (int i = 0; i < n; i+=2) {
//                    sum1 += arr[i];
//                }
//
//                for (int i = 1; i < n; i+=2) {
//                    sum2 += arr[i];
//                }
//
//                ans = Math.max(sum1, sum2);
//            } else {
//
//            }
        }
    }

    private static void sort(double[] arr) {
        Double[] objArr = Arrays.stream(arr).boxed().toArray(Double[]::new);
        Arrays.sort(objArr);
        for (int i = 0; i < arr.length; i++) {
            arr[i] = objArr[i];
        }
    }

    private static void sort(int[] arr) {
        Integer[] objArr = Arrays.stream(arr).boxed().toArray(Integer[]::new);
        Arrays.sort(objArr);
        for (int i = 0; i < arr.length; i++) {
            arr[i] = objArr[i];
        }
    }

    private static void sort(long[] arr) {
        Long[] objArr = Arrays.stream(arr).boxed().toArray(Long[]::new);
        Arrays.sort(objArr);
        for (int i = 0; i < arr.length; i++) {
            arr[i] = objArr[i];
        }
    }

    private static void solve() {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Task task = new Task();
        task.solve(1, in, out);
        out.close();
    }

    public static void main(String[] args) {
        new Thread(null, () -> solve(), "1", 1 << 26).start();
    }

    static class InputReader {

        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

        public double nextDouble() {
            return Double.parseDouble(next());
        }

    }

}

Measured memory_bytes: 106776