#include <bits/stdc++.h>
using namespace std;
const int MOD = 1000000007;
int main() {
  int N;
  cin >> N;
  vector<long long> A(N);
  vector<long long> accum(N + 1, 0);
  for (long long i = 0; i < (long long)N; i++) {
    cin >> A[i];
    accum[i + 1] = accum[i] + A[i];
  }
  map<long long, long long> nums;
  for (long long i = 0; i < (long long)N; i++) nums[accum[i]]++;
  long long ans = 0;
  for (auto it : nums) {
    long long num = it.second;
    ans += num * (num - 1) / 2;
  }
  cout << ans << endl;
}
