#include <bits/stdc++.h>
using namespace std;
int main(void) {
  int N, cou;
  cou = 0;
  cin >> N;
  vector<long long int> A(N);
  vector<long long int> sum(N);
  map<long long int, long long int> mp;
  for (int i = 0; i < N; i++) {
    cin >> A[i];
    if (i == 0)
      sum[i] = A[i];
    else
      sum[i] = sum[i - 1] + A[i];
  }
  sum.push_back(0);
  for (int i = 0; i <= N; i++) {
    mp[sum[i]]++;
    cou += mp[sum[i]] - 1;
  }
  cout << cou << endl;
}
