https://www.acmicpc.net/problem/2579
import java.util.*;
public class Main {
public static void main(String args[]) {
Scanner s=new Scanner(System.in);
int n=s.nextInt();
int arr[]=new int[n+1];
int num[]=new int[n+1];
for(int i=1;i<=n;i++) arr[i]=s.nextInt();
num[1]=arr[1];
if(n>1) num[2]=arr[1]+arr[2];
for(int i=3;i<=n;i++){
num[i]=Math.max(num[i-2],num[i-3]+arr[i-1])+arr[i];
}
System.out.print(num[n]);
}
}