#include<iostream>
#include<conio.h>
#include<vector>
#include<queue>
#include<bits/stdc++.h>
#include<conio.h>
#include<cmath>
#include<string>
#include<stdio.h>
#include<algorithm>
#define ff first
#define ss second
#define pb(a) push_back(a)
#define mk(a,b) make_pair(a,b)
using namespace std;
typedef long long ll;
typedef float fl;
typedef pair<int, int> pii;
typedef vector <int> vint;
typedef vector < pii > pvint;
typedef vector <bool> bvint;
typedef vector <vint> vvint;
const int inf=2e9;
int a[10000], t[400004];
void build_tree(int v, int tl, int tr){
if(tl==tr) t[v]=a[tl];
else{
int tm=(tl+tr)/2;
build_tree(v*2, tl ,tm);
build_tree(v*2+1, tm+1, tr);
t[v]=t[v*2]+t[v*2+1];
}
}
int get_min(int v, int tl , int tr, int l, int r){
if(l<=tl && tr<=r) return t[v];
if(l>tr || r<tl) return inf;
return min(get_min( v*2, tl , (tl+tr)/2, l,r ), get_min(v*2+1, (tl+tr)/2+1, tr, l,r ) );
}
int main()
{
int n; cin>>n; for(int i=1;i<=n;i++) cin>>a[i];
build_tree(1, 1, 5);
cout<<get_min(1, 1, 5, 2,4)<<endl;
return 0;
}
I2luY2x1ZGU8aW9zdHJlYW0+CiNpbmNsdWRlPGNvbmlvLmg+CiNpbmNsdWRlPHZlY3Rvcj4KI2luY2x1ZGU8cXVldWU+CiNpbmNsdWRlPGJpdHMvc3RkYysrLmg+CiNpbmNsdWRlPGNvbmlvLmg+CiNpbmNsdWRlPGNtYXRoPgojaW5jbHVkZTxzdHJpbmc+CiNpbmNsdWRlPHN0ZGlvLmg+CiNpbmNsdWRlPGFsZ29yaXRobT4KI2RlZmluZSBmZiBmaXJzdAojZGVmaW5lIHNzIHNlY29uZAojZGVmaW5lIHBiKGEpIHB1c2hfYmFjayhhKQojZGVmaW5lIG1rKGEsYikgbWFrZV9wYWlyKGEsYikKdXNpbmcgbmFtZXNwYWNlIHN0ZDsKdHlwZWRlZiBsb25nIGxvbmcgbGw7CnR5cGVkZWYgZmxvYXQgZmw7CnR5cGVkZWYgc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