#include<iostream>
#include<algorithm>
using namespace std;
int main(){
  long long n,i,k,ans = 0,c = 0;cin >> n;
  long long a[n+1];a[0] = 0;
  for(i=1;i<=n;i++){
    cin >> k;a[i] = a[i-1]+k;
  }
  sort(a,a+n+1);
  for(i=1;i<=n;i++){
    if(a[i] == a[i-1]){
      c++;ans += c;
    } else c = 0;
  }
  cout << ans << endl;
}