import java.io.*; public class Main{ public static void main(String[] args)throws IOException{ BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); String str = null; while((str = in.readLine()) != null){ int n = Integer.parseInt(str); String[] arr = in.readLine().split(" "); int[] res = new int[arr.length]; for(int i = 0;i < arr.length; i++){ res[i] = Integer.parseInt(arr[i]); } int post = 0; int pre = 0; int dest = 0; int i = 2; while(i <= n){ dest = Math.min(post+res[i-2],pre+res[i-1]); post = pre; pre = dest; i ++; } System.out.println(dest); } } }