import std.algorithm;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

long test(in int[] a, const int n) {
  const int m = n / 2;
  long[] prev;
  int e;
  const long minf = long.min / 2;
  foreach (l; 1 .. m + 1) {
    const int minlen = 2 * (m + 1 - l) - 1;
    const int last = n - minlen;
    if (l == 1) {
      prev = a[0 .. last + 1].map!(to!long).array;
    } else {
      const int pl = prev.length.to!int;
      auto next = new long[pl + last - e];
      next[] = minf;
      foreach (j; 0 .. pl) {
        const int delta = e - (pl - 1); 
        //int o = j + delta;
        foreach (k; j + 2 .. next.length) {
          long w = prev[j] + a[k + delta];
          if (next[k] < w) next[k] = w;
        }
      }
      while (next.front == minf) next.popFront();
      prev = next;
    }
    e = last;
    debug stderr.writeln ("prev = ", prev, ", e = ", e);
  }
  return maxElement(prev);
}

/*
long odd(int[] a) {
  //auto x = new long[a.length];
  auto s = new long[a.length + 2];
  foreach_reverse (i; 0 .. a.length) {
    s[i] = s[i + 2] + a[i];
  }
  long 
  const int
  foreach (j; 0 .. a.length) {
  }
}

long even(int[] a) {
  long res = long.max;
  foreach (i; 0 .. 2) {
    long s;
    for (int j = i; j < a.length; j += 2) s += a[j];
    res = max (res, s);
  }
  return res;
}
*/

void main() {
  int n;
  readf (" %d", &n);
  auto a = new int[n];
  foreach (t; 0 .. n) {
    readf (" %d", &a[t]);
  }
  writeln(test(a,n));
}

