import java.util.Scanner;

/**
 * @author supermejane
 * @date 2025/10/7
 * @description
 */
public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);

        int n = in.nextInt();
        int[] a = new int[n], dp = new int[n + 1];
        for (int i = 0; i < n; i++) {
            a[i] = in.nextInt();
        }

        for (int i = 1; i <= n; i++) {
            dp[i] = i > 1 ? Math.min(dp[i - 1], dp[i - 2]) + a[i - 1] : a[i - 1];
        }

        System.out.println(dp[n]);
    }
}