import java.io.*; import java.util.StringTokenizer; class Main{ static final PrintWriter out=new PrintWriter(System.out); public static void main(String[] args) throws IOException{ BufferedReader br=new BufferedReader(new InputStreamReader(System.in)); String line=""; while((line=br.readLine())!=null&&!line.isEmpty()){ int n=Integer.parseInt(line); int[] dp=new int[n+2]; int[] v=new int[n]; StringTokenizer st=new StringTokenizer(br.readLine()); for(int i=0;i=0;i--){ dp[i]=Math.max(dp[i+1],dp[i+2]+v[i]); } out.println(dp[0]); out.flush(); } } }