using System;
using System.Linq;
// (づ°ω°)づミ★゜・。。・゜゜・。。・゜☆゜・。。・゜゜・。。・゜
public class Solver
{
static void Main()
{
int n = int.Parse(Console.ReadLine());
var a = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
var dp1 = new int[n + 1, 3 * n + 1];
var dp2 = new int[n + 1, 3 * n + 1];
for (int i = 0; i < 3 * n; i++)
{
for (int j = 0; j <= n; j++)
{
dp1[j, i + 1] = Math.Max(dp1[j, i + 1], dp1[j, i]);
dp2[j, i + 1] = Math.Max(dp2[j, i + 1], dp2[j, i]);
if (j < n && i < 3 * n - 1)
{
dp1[j + 1, i + 2] = Math.Max(dp1[j + 1, i + 2], dp1[j, i] + a[i]);
dp2[j + 1, i + 2] = Math.Max(dp2[j + 1, i + 2], dp2[j, i] + a[i + 1]);
}
}
}
Console.WriteLine(Math.Max(dp1[n, 3 * n], dp2[n, 3 * n]));
}
}
dXNpbmcgU3lzdGVtOwp1c2luZyBTeXN0ZW0uTGlucTsKCi8vICjjgaXCsM+JwrAp44Gl776Q4piF44Kc44O744CC44CC44O744Kc44Kc44O744CC44CC44O744Kc4piG44Kc44O744CC44CC44O744Kc44Kc44O744CC44CC44O744KcCnB1YmxpYyBjbGFzcyBTb2x2ZXIKewogICAgc3RhdGljIHZvaWQgTWFpbigpCiAgICB7CiAgICAgICAgaW50IG4gPSBpbnQuUGFyc2UoQ29uc29sZS5SZWFkTGluZSgpKTsKICAgICAgICB2YXIgYSA9IENvbnNvbGUuUmVhZExpbmUoKS5TcGxpdCgnICcpLlNlbGVjdChpbnQuUGFyc2UpLlRvQXJyYXkoKTsKCiAgICAgICAgdmFyIGRwMSA9IG5ldyBpbnRbbiArIDEsIDMgKiBuICsgMV07CiAgICAgICAgdmFyIGRwMiA9IG5ldyBpbnRbbiArIDEsIDMgKiBuICsgMV07CiAgICAgICAgZm9yIChpbnQgaSA9IDA7IGkgPCAzICogbjsgaSsrKQogICAgICAgIHsKICAgICAgICAgICAgZm9yIChpbnQgaiA9IDA7IGogPD0gbjsgaisrKQogICAgICAgICAgICB7CiAgICAgICAgICAgICAgICBkcDFbaiwgaSArIDFdID0gTWF0aC5NYXgoZHAxW2osIGkgKyAxXSwgZHAxW2osIGldKTsKICAgICAgICAgICAgICAgIGRwMltqLCBpICsgMV0gPSBNYXRoLk1heChkcDJbaiwgaSArIDFdLCBkcDJbaiwgaV0pOwogICAgICAgICAgICAgICAgaWYgKGogPCBuICYmIGkgPCAzICogbiAtIDEpCiAgICAgICAgICAgICAgICB7CiAgICAgICAgICAgICAgICAgICAgZHAxW2ogKyAxLCBpICsgMl0gPSBNYXRoLk1heChkcDFbaiArIDEsIGkgKyAyXSwgZHAxW2osIGldICsgYVtpXSk7CiAgICAgICAgICAgICAgICAgICAgZHAyW2ogKyAxLCBpICsgMl0gPSBNYXRoLk1heChkcDJbaiArIDEsIGkgKyAyXSwgZHAyW2osIGldICsgYVtpICsgMV0pOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICB9CiAgICAgICAgfQoKICAgICAgICBDb25zb2xlLldyaXRlTGluZShNYXRoLk1heChkcDFbbiwgMyAqIG5dLCBkcDJbbiwgMyAqIG5dKSk7CiAgICB9Cn0=