#include <bits/stdc++.h>
using namespace std;
inline int toInt(string s) {
  int v;
  istringstream sin(s);
  sin >> v;
  return v;
}
template <class T>
inline string toString(T x) {
  ostringstream sout;
  sout << x;
  return sout.str();
}
template <class T>
inline T sqr(T x) {
  return x * x;
}
const double EPS = 1e-10;
const double PI = acos(-1.0);
long long combi(long long n, long long k) {
  std::map<std::string, long long> memo;
  if (n == k || k == 0)
    return 1;
  else {
    std::string key = std::to_string(n) + std::to_string(k);
    if (memo.count(key) != 0) {
      return memo[key];
    } else {
      long long out = combi(n - 1, k - 1) + combi(n - 1, k);
      memo[key] = out;
      return out;
    }
  }
}
bool compare_by_b(pair<long long, long long> a, pair<long long, long long> b) {
  if (a.second != b.second) {
    return a.second < b.second;
  } else {
    return a.first < b.first;
  }
}
void solve(long long N, std::vector<long long> A) {
  vector<long long> s;
  long long sum = 0;
  for (int i = (0); i < (N); ++i) {
    s.push_back(A[i] + sum);
    sum += A[i];
  }
  s.push_back(0);
  sort((s).begin(), (s).end());
  map<long long, long long> m;
  for (int i = (0); i < (s.size()); ++i) {
    m[s[i]] = 0;
  }
  for (int i = (0); i < (s.size()); ++i) {
    m[s[i]]++;
  }
  long long ans = 0;
  for (int i = (0); i < (s.size()); ++i) {
    if (m[s[i]] >= 2) {
      ans += combi(m[s[i]], 2);
      m[s[i]] = 0;
    }
  }
  cout << ans << endl;
}
int main() {
  long long N;
  scanf("%lld", &N);
  std::vector<long long> A(N);
  for (int i = 0; i < N; i++) {
    scanf("%lld", &A[i]);
  }
  solve(N, std::move(A));
  return 0;
}
