#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define fi first
#define se second
const int MOD = 1000000007;
const int INF = 1e18;
const int N = 3e5 + 10;

void solve() {
ll n;
cin>>n;
vector<ll>a(n+1);
for(ll i=1;i<=n;i++) cin>>a[i];
vector<ll>dp(n+1);
dp[1]=a[1];
for(ll i=2;i<=n;i++){
	dp[i]=min(dp[i-1],dp[i-2])+a[i];
//核心代码,第一次做dp,写的代码有点死板,看了题解才发现状态转移没搞清,这里其实就是跳跃一格还是跳跃两格,取最小即可	
}
cout<<dp[n]<<endl;
return;
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    ll T = 1;
    //cin >> T;
    while (T--)
        solve();
    return 0;
}