import java.util.Scanner;
// 注意类名必须为 Main, 不要有任何 package xxx 信息
public class Main {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int n = in.nextInt();
// 注意这一题,不是cost的最后一个就是楼梯顶,而是cost的后一个才是楼梯顶,楼梯顶是没有cost的,所以需要n+1,多算一层
int[] costs = new int[n + 1];
int i = 0;
// 注意 hasNext 和 hasNextLine 的区别
while (in.hasNextInt()) { // 注意 while 处理多个 case
costs[i] = in.nextInt();
i++;
}
if(n == 1){
System.out.println(costs[n - 1]);
return;
}
costs[n] = 0;
int[] dp = new int[n + 1];
dp[0] = 0;
dp[1] = 0;
for(int j = 2; j < n + 1; j++){
dp[j] = Math.min(dp[j - 1] + costs[j - 1], dp[j - 2] + costs[j - 2]);
}
System.out.println(dp[n]);
}
}