#include<iostream>
#include<algorithm>
#include<map>
using namespace std;
int main() {
  long long cnt=0,ans=0;
  int n;
  cin >> n;
  map<long long,long long> mp;
  mp[0]=1;
  for(int i=0; i<n; i++) {
    long long a;
    cin >> a;
    cnt+=a;
    ans+=mp[cnt];
    mp[cnt]++;
  }
  cout << ans << endl;
}