#include<bits/stdc++.h>

using namespace std;

using int64 = long long;

int main() {
  int N;
  cin >> N;
  map< int64, int > mp;
  int64 sum = 0;
  mp[0]++;

  int64 ret = 0;
  for(int i = 0; i < N; i++) {
    int x;
    cin >> x;
    sum += x;
    ret += mp[sum];
    mp[sum]++;
  }

  cout << ret << endl;

}