#include <iostream>
#include <vector>
#include <string>
#include <cstdlib>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <stack>
#include <math.h>
#define rep(i, n) for(int i = 0; i < (n); ++i)
using namespace std;

template<class T> inline bool chmax(T& a, T b){ if(a < b) { a=b; return 1; }return 0;}
template<class T> inline bool chmin(T& a, T b){ if(a > b) { a=b; return 1; }return 0;}

int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
const long long INF = 1LL << 60;
// spring s; cin >> s;
// cout << res << endl;
// --------write my code!!!!!----------//

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+1) nums[s[i]]++;
  
  long long res = 0;
  for(auto it : nums) {
    long long num = it.second;
    res += num * (num-1) / 2;
  }
  cout << res << endl;
}
