#include <bits/stdc++.h>
using namespace std;

int main(){
  int N;
  cin >> N;

  vector<int64_t> data(N);
  for(int i=0; i<N; i++){
    cin >> data.at(i);
  }

  unordered_map<int64_t, int64_t> freq_altsum;
  freq_altsum[0]++;
  int64_t altsum= 0;
  for(int i=0; i<N; i++){
    altsum= (i%2==0) ?  data.at(i)+ altsum
                     : -data.at(i)+ altsum;
    freq_altsum[altsum]++;
  }

  // for(const auto& [val,freq]:freq_altsum){
  //   cout << val <<": "<< freq << endl;
  // }

  int64_t ans= 0;
  for(const auto& [val,freq]:freq_altsum){
    ans+= freq* (freq- 1)/ 2;
  }
  
  cout << ans << endl;
}
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
#define int long long
#define fs first
#define sc second
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pb push_back
#define MP make_pair
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

signed main() {
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#ifdef FlameDragon
    freopen("in.txt", "r", stdin);
#endif
    int n;
    cin >> n;
    vector<int> a(n + n);
    vector<pair<int, int>> b(n + n);
    for (int i = 0; i < n + n; i++) {
        cin >> a[i];
        b[i] = {a[i], i};
    }
    vector<int> c(n + n);
    sort(all(b));
    for (int i = 0; i < n; i++) {
        c[b[i].second] = true;
    }
    string ans(n + n, '(');
    vector<pair<int, char>> st;
    for (int i = 0; i < n + n; i++) {
        if (!sz(st)) {
            st.push_back({c[i], '('});
        } else if (st.back().first == c[i]) {
            ans[i] = st.back().second;
            st.push_back(st.back());
        } else {
            ans[i] = st.back().second ^ '(' ^ ')';
            st.pop_back();
        }
    }
    cout << ans << '\n';
}
