#include <bits/stdc++.h>
using namespace std;
int N;
int main() {
  cin >> N;
  vector<long long> A;
  for (int i = 0; i < N; i++) {
    long long a;
    scanf("%lld", &a);
    A.push_back(a);
  }
  vector<long long> s(N + 1, 0);
  map<long long, long long> nums;
  for (int i = 0; i < N; i++) s[i + 1] = s[i] + A[i];
  for (int i = 0; i < N + 1; i++) nums[s[i]]++;
  long long res = 0;
  for (int i = 0; i < N + 1; i++) {
    auto p = nums[i];
    long long num = p;
    res += num * (num - 1) / 2;
  }
  cout << res << '\n';
}
