#include<bits/stdc++.h>
using namespace std;
#define INFTY (1<<29)
#define rep(i,n) for (ll i = 0; i < (n); ++i)
typedef long long int ll;
using ipair = pair<int,int>;
using lpair = pair<ll,ll>;
bool operator< (const ipair a, const ipair b){return a.first < b.first;};
const ll MOD=998244353;
const ll MAX = 5100000;
const int di[4] = {-1,0,1,0};
const int dj[4] = {0,-1,0,1};

int main(){
    int n,sum = 0;cin>>n;
    vector<int> t(n);
    rep(i,n){
        cin>>t[i];
        sum += t[i];
    }
    vector<int> cook(sum+1,0);
    cook[0] = 1;
    rep(i,n){
        vector<int> new_cook = cook;
        rep(j,sum+1){
            if(cook[j]){
                //cout<<j<<endl;
                new_cook[j+t[i]] = 1;
            }
        }
        cook = new_cook;
    }
    
    int ans = 100010;
    for(int i = 1;i<=sum;i++){
        if(cook[i]){
            ans = min(ans,max(i,sum-i));
        }
    }
    cout<<ans<<endl;
    return 0;
}
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define SZ(x) ((int)(x).size())
#define FOR(var, begin, end) for (int var = (begin); var <= (end); var++)
#define RFOR(var, begin, end) for (int var = (begin); var >= (end); var--)
#define REP(var, length) FOR(var, 0, length - 1)
#define RREP(var, length) RFOR(var, length - 1, 0)
#define EACH(value, var) for (auto value : var)
#define SORT(var) sort(var.begin(), var.end())
#define REVERSE(var) reverse(var.begin(), var.end())
#define RSORT(var) \
  SORT(var);       \
  REVERSE(var)
#define OPTIMIZE_STDIO         \
  ios::sync_with_stdio(false); \
  cin.tie(0);                  \
  cout.precision(10);          \
  cout << fixed
#define endl '\n'

const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;

void solve(istream& cin, ostream& cout) {
  int n;
  cin >> n;
  vector<ll> a(n);
  REP(i, n) cin >> a[i];
  vector<ll> c(n + 1);
  c[0] = 0;
  REP(i, n) {
    if (i % 2 == 0) c[i + 1] = c[i] + a[i];
    else
      c[i + 1] = c[i] - a[i];
  }
  map<ll, ll> mp;
  FOR(i, 0, n) mp[c[i]]++;
  ll ans = 0;
  EACH(e, mp) {
    ans += e.second * (e.second - 1) / 2;
  }
  cout << ans << endl;
}

#ifndef TEST
int main() {
  OPTIMIZE_STDIO;
  solve(cin, cout);
  return 0;
}
#endif
