#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = 1e9;
int factorial(int n) {
  int res = 1;
  if (n != 0) {
    res *= n;
    res *= factorial(n - 1);
  }
  return res;
}
int nCr(int n, int r) {
  return factorial(n) / (factorial(r) * factorial(n - r));
}
int main() {
  int N;
  cin >> N;
  vector<ll> A(N + 1, 0);
  for (int(i) = 0; (i) < (N); ++(i)) cin >> A[i + 1], A[i + 1] += A[i];
  map<ll, int> mp;
  for (int(i) = 0; (i) < (N + 1); ++(i)) ++mp[A[i]];
  int ans = 0;
  for (auto e : mp)
    if (e.second > 1) ans += nCr(e.second, 2);
  cout << (ans) << endl;
}
