#include <stdio.h>
int main() {
int n;
scanf("%d", &n);
int dp[n + 1];
int cost[n];
for (int i = 0; i < n; i++) {
scanf("%d", &cost[i]);
}
dp[0] = 0;
dp[1] = 0;
for (int j = 2; j <= n; j++) {
dp[j] = dp[j - 1] + cost[j - 1] < dp[j - 2] + cost[j - 2] ? dp[j - 1] + cost[j -
1] : dp[j - 2] + cost[j - 2];
}
printf("%d",dp[n]);
return 0;
}

京公网安备 11010502036488号