#include <bits/stdc++.h>
using namespace std;

int main(){

  long long N,A;

  cin >> N;

  long long ans = 0,nsum = 0;

  map <long long,long long> dic;
  dic[0] = 1;

  for (int i = 0 ; i < N ; i++){

    cin >> A;

    nsum += A;

    ans += dic[nsum];

    dic[nsum] += 1;

  }

  cout << ans << endl;

  return 0;

}
