#include <bits/stdc++.h>
#define mod 1000000007
#define fast_io ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define vi vector<int>
#define vl vector<ll>
#define REP(s, e) for (auto i = s; i <= e; i++)
#define show(s) cout<<s<<" "
#define MAXI 2147483647
#define MAXL 9223372036854775807
#define FOR(a,b) for (ll i = a; i < b; i++)
using namespace std;
typedef signed long long int ll;

int main() {
    fast_io;
    int n; cin >> n;
    vector<string> opers = {"dummy"};
    for (int i = 0; i < n; i++)
    {
        string inp; cin >> inp;
        opers.push_back(inp);
    }
    vector<pair<ll,ll>> dp;
    dp.push_back({1,0});
    for (int i = 1; i <= n; i++)
    {
        if (opers[i] == "OR")
        {
            dp.push_back({dp[i-1].first * 2 + dp[i-1].second, dp[i-1].second});
        } else
        {
            dp.push_back({dp[i-1].first, dp[i-1].second * 2 + dp[i-1].first});
        }
    }
    ll ans1 = dp[n].first;
    dp.clear();
    dp.push_back({0,1});
    for (int i = 1; i <= n; i++)
    {
        if (opers[i] == "OR")
        {
            dp.push_back({dp[i-1].first * 2 + dp[i-1].second, dp[i-1].second});
        } else
        {
            dp.push_back({dp[i-1].first, dp[i-1].second * 2 + dp[i-1].first});
        }
    }
    ll ans2 = dp[n].first;
    cout << ans1 + ans2;
}

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

int main(){
  int N;cin>>N;
  vector<long> A(N);
  for(int i=0;i<N;i++) cin>>A.at(i);
  map<long,vector<int>> x;
  long cnt=1,m=0;
  x[0].push_back(-1);
  for(int i=0;i<N;i++){
    m+=cnt*A[i];
    x[m].push_back(i);
    cnt*=-1;
  }
  long ans=0;
  for(auto [c,v]:x){
    m=v.size();
    ans+=m*(m-1)/2;
  }
  cout<<ans<<endl;
}