package main import ( "bufio" "fmt" "os" "strconv" ) func max(n1 int, n2 int) int { if n1 > n2 { return n1 } else { return n2 } } func main() { sc := bufio.NewScanner(os.Stdin) sc.Split(bufio.ScanWords) sc.Scan(); n, _ := strconv.Atoi(sc.Text()) vs := make([]int, n) for i := 0; i < n; i++ { sc.Scan(); v, _ := strconv.Atoi(sc.Text()) vs[i] = v } dp := make([]int, n) if n >= 1 { dp[0] = vs[0] } if n >= 2 { dp[1] = vs[1] } if n >= 3 { dp[2] = vs[0] + vs[2] } if n >= 4 { for i := 3; i < n; i++ { dp[i] = max(dp[i - 2], dp[i - 3]) + vs[i] } } if n >= 2 { fmt.Println(max(dp[n - 1], dp[n - 2])) } else { fmt.Println(dp[0]) } }