#include <bits/stdc++.h>
using namespace std;
int N;
long long A[200000];
long long cnt[200000];
int main() {
  scanf("%d", &N);
  for (int i = 0; i < N; i++) scanf("%lld", &A[i]);
  for (int i = 1; i < N; i++) A[i] += A[i - 1];
  vector<long long> b(N);
  for (int i = 0; i < N; i++) b.push_back(A[i]);
  sort(b.begin(), b.end());
  b.erase(unique(b.begin(), b.end()), b.end());
  long long ans = 0;
  for (int i = 0; i < N; i++) {
    auto itr = lower_bound(b.begin(), b.end(), A[i]);
    int n = distance(b.begin(), itr);
    ans += cnt[n];
    if (A[i] == 0) ans++;
    cnt[n]++;
  }
  cout << ans << endl;
  return 0;
}
