/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
/**
*
* @author RYMA
*/
import java.io.BufferedOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.util.*;
public class Main {
public static void main
(String[] args
) { new Main();
}
public int min(int a,int b){
return (a>b)? b:a;
}
public int min(int a,int b,int c){
int x = min(a,b);
return min(x,c);
}
public Main() {
FasterScanner sc
= new FasterScanner
(System.
in); FastPrinter printer = new FastPrinter();
int N = sc.nextInt();
int a[] = new int[N];
for(int i=0;i<N;++i){
a[i]=sc.nextInt();
}
if(N<=3){
}
else{
int b[] = new int[N];
b[0]=a[0];
b[1]=a[1];
b[2]=a[2];
for(int i=3;i<N;++i){
int x = b[i-1]>b[i-2] ? b[i-2]:b[i-1];
int y = b[i-3]>x ? x : b[i-3];
b[i]= y+a[i];
}
int x = b[N-1]>b[N-2] ? b[N-2]:b[N-1];
int y = b[N-3]>x ? x : b[N-3];
}
printer.close();
sc.close();
}
public class FasterScanner {
private byte[] buf = new byte[1024];
private int curChar;
private int numChars;
public FasterScanner() {
}
mIs = is;
}
public int read() {
if (numChars == -1)
throw new InputMismatchException();
if (curChar >= numChars) {
curChar = 0;
try {
numChars = mIs.read(buf);
throw new InputMismatchException();
}
if (numChars <= 0)
return -1;
}
return buf[curChar++];
}
int c = read();
while (isSpaceChar(c))
c = read();
StringBuilder res = new StringBuilder();
do {
res.appendCodePoint(c);
c = read();
} while (!isEndOfLine(c));
return res.toString();
}
int c = read();
while (isSpaceChar(c))
c = read();
StringBuilder res = new StringBuilder();
do {
res.appendCodePoint(c);
c = read();
} while (!isSpaceChar(c));
return res.toString();
}
public long nextLong() {
int c = read();
while (isSpaceChar(c))
c = read();
int sgn = 1;
if (c == '-') {
sgn = -1;
c = read();
}
long res = 0;
do {
if (c < '0' || c > '9')
throw new InputMismatchException();
res *= 10;
res += c - '0';
c = read();
} while (!isSpaceChar(c));
return res * sgn;
}
public int nextInt() {
int c = read();
while (isSpaceChar(c))
c = read();
int sgn = 1;
if (c == '-') {
sgn = -1;
c = read();
}
int res = 0;
do {
if (c < '0' || c > '9')
throw new InputMismatchException();
res *= 10;
res += c - '0';
c = read();
} while (!isSpaceChar(c));
return res * sgn;
}
public boolean isSpaceChar(int c) {
return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
}
public boolean isEndOfLine(int c) {
return c == '\n' || c == '\r' || c == -1;
}
public void close() {
try {
mIs.close();
e.printStackTrace();
}
}
}
class FastPrinter {
/**
* Initialize the writer.
*/
public FastPrinter() {
}
/**
* Print the given String and add a newline.
*
* @param string
* The given String.
*/
public void println
(String string
) { writer.println(string);
}
/**
* Print the given String.
*
* @param string
* The given String.
*/
public void print
(String string
) { writer.print(string);
}
public void close() {
writer.close();
}
}
}