#include <bits/stdc++.h>
using namespace std;
const long long int mod = 1e9 + 7;
vector<long long> A(200001);
vector<long long> s(200001);
int main() {
  long long N, res = 0;
  cin >> N;
  A.resize(N);
  s.resize(N);
  for (int i = (0); i < (N); i++) cin >> A[i];
  for (int i = (0); i < (N); i++) s[i + 1] = s[i] + A[i];
  sort(s.begin(), s.end());
  long long count = 0;
  for (int i = (0); i < (N); i++) {
    if (s[i] == s[i + 1]) {
      count++;
    } else {
      res += (count * (count + 1)) / 2;
      count = 0;
    }
  }
  res += (count * (count + 1)) / 2;
  cout << res << endl;
}
