#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
 
#define rep for(int i = 0;i<n;i++)
const long long MOD = 1000000007;

vector<vector<int>> graph(100001,vector<int>());

int main(){
  int n;cin >> n;
  int a[n];rep{
    cin >> a[i];
  }
  int b[n+1] = {};
  b[0] = 0;
  long long ans = 0;
  map<int,int> mp;mp[0]++;
  for(int i = 1;i<=n;i++){
    b[i] = a[i-1] + b[i-1];
    mp[b[i]]++;
  }

  for(auto i: mp){
    int a = i.second;
    ans += a*(a-1)/2;
  }
  cout << ans << endl;
}