// Arup Guha
// 4/6/2024
// Solution to Kattis Problem: Hopavinna
// https://open.kattis.com/problems/hopavinna

import java.util.*;

public class hopavinna {
	
	public static void main(String[] args) {
	
		Scanner stdin = new Scanner(System.in);
		int n = stdin.nextInt();
		
		// Read in all times for homework.
		int[] cost = new int[n];
		for (int i=0; i<n; i++)
			cost[i] = stdin.nextInt();
		
		// index 0 is 0 tasks, index 1 is ending on the first task.
		int[] dp = new int[n+1];
		dp[0] = 0;
		dp[1] = cost[0];
		
		// Get best schedule for ending on assignment i.
		for (int i=2; i<=n; i++) {
		
			// Take the better of ending at i-2 or i-1 and add this item to it.
			dp[i] = Math.min(dp[i-1], dp[i-2])+ cost[i-1];
		}
		
		// I can either end with the last task or second to last.
		System.out.println(Math.min(dp[n], dp[n-1]));
	}
}