#include <iostream>
#include <vector>
#include <algorithm>

#define rep(i,n) for (int i=0; i<n; i++)

using namespace std;
typedef long long ll;

int main(){
  int N; cin >> N;
  vector<long long> a(N);
  rep(i,N) cin >> a[i];

  //累積和と連想配列
  vector<long long> s(N+1, 0);
  map<long long, long long> nums;
  rep(i,N) s[i+1] = s[i] + a[i];
  rep(i,N) nums[s[i]]++;

  //集計処理
  long long res = 0;
  for(auto it: nums){
    long long num = it.second;
    res += num*(num-1)/2; //numC_2
  }
  cout << res << endl;


}
