using namespace std; const int N = 1e9; int dp[1000005]; int t[1000005];
int main() {
int n;
cin >> n;
for (int x = 1; x <= n; x++)
cin >> t[x];
for (int x = 0; x < 1000005; x++)
dp[x] = N;
dp[0] = 0;
dp[1] = t[1];
dp[2] = t[2];
for (int x = 3; x <= n + 1; x++) {
dp[x] = min(dp[x], dp[x - 1]);
dp[x] = min(dp[x], dp[x - 2]);
dp[x] = min(dp[x], dp[x - 3]);
dp[x] += t[x];
}
cout << dp[n + 1];
return 0;
}
比赛已结束。