package main import ( "bufio" "fmt" "os" "strconv" ) func nextInt(sc *bufio.Scanner) int { sc.Scan() i, e := strconv.Atoi(sc.Text()) if e != nil { panic(e) } return i } func max(list []int) int { maxNum := 0 for _, n := range list { if n > maxNum { maxNum = n } } return maxNum } func main() { sc := bufio.NewScanner(os.Stdin) sc.Split(bufio.ScanWords) n := nextInt(sc) dp := make([]int, n) for i := 0; i < n; i++ { sumV := nextInt(sc) if i == 2 { sumV += dp[0] } else if i > 2 { sumV += max(dp[i-3 : i-1]) } dp[i] = sumV } start := max([]int{0, n - 2}) fmt.Println(max(dp[start:])) }