#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10;
int dp[N], cost[N];
int n;
int main()
{
cin >> n;
for(int i = 0; i < n; i ++) cin >> cost[i];
dp[0] = 0, dp[1] = 0;
for(int i = 2; i <= n; i ++)
dp[i] = min(dp[i - 2] + cost[i -2], dp[i - 1] + cost[i - 1]);
cout << dp[n];
return 0;
}

京公网安备 11010502036488号