#include <bits/stdc++.h>
using namespace std;
int INF = 1LL << 30;
int MOD = 1e9 + 7;
int main() {
  int N;
  cin >> N;
  long long cnt = 0;
  vector<int> A(N);
  for (int i = 0; i < N; i++) {
    cin >> A[i];
  }
  vector<long long> accum(N);
  accum[0] = A[0];
  for (int i = 1; i < N; i++) {
    accum[i] = A[i] + accum[i - 1];
  }
  map<long long, int> mp;
  for (int i = 0; i < N; i++) {
    mp[accum[i]]++;
  }
  for (auto p : mp) {
    if (p.first) {
      cnt += p.second * (p.second - 1) / 2;
    } else {
      cnt += p.second * (p.second - 1) / 2 + p.second;
    }
  }
  cout << cnt << endl;
}
