#include <bits/stdc++.h>
using namespace std;
int N;
long long A[200000];
long long cnt[200000];
int main() {
  cin >> N;
  for (int i = 0; i < N; i++) cin >> 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[i] = 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++) cerr << A[i] << " ";
  cerr << endl;
  for (int i = 0; i < N; i++) cerr << b[i] << " ";
  cerr << endl;
  for (int i = 0; i < N; i++) {
    auto itr = find(b.begin(), b.end(), A[i]);
    int n = b.begin() - itr;
    ans += cnt[n];
    if (A[i] == 0) ans++;
    cnt[n]++;
  }
  cout << ans << endl;
  return 0;
}
