package main

import (
    "fmt"
)

func min(a int, b int) int {
    if a < b {
        return a
    }
    return b
}

func minCosts(costs []int, n int) int {
    c := 0
    if n <= 1 {
        return c
    }
    one_cost, two_cost := costs[0], costs[1]
    for i:=2; i<n; i++ {
        c = min(one_cost, two_cost)
        one_cost = two_cost
        two_cost = c + costs[i]
    }
    return min(one_cost, two_cost)
}

func main() {
    n:=0
    costs := []int{}
    fmt.Scan(&n)
    for i:=1;i<=n;i++ {
        num := 0
        fmt.Scan(&num)
        costs = append(costs, num)
    }
    fmt.Print(minCosts(costs, n))
}