#include <bits/stdc++.h>
using namespace std;
using lint = long long;
const int INF = 1e9;
const lint LINF = 1e18;
const lint MOD = 1e9 + 7;
const double EPS = 1e-10;
int main() {
  int N;
  cin >> N;
  vector<lint> A(N, 0);
  for (int i = (int)(0); i < (int)(N); i++) cin >> A[i];
  vector<lint> L(N + 1, 0);
  for (int i = (int)(0); i < (int)(N); i++) L[i + 1] = L[i] + A[i];
  cerr << "A"
          ":[ ";
  for (auto macro_vi : A) {
    cerr << macro_vi << " ";
  }
  cerr << "]" << endl;
  ;
  cerr << "L"
          ":[ ";
  for (auto macro_vi : L) {
    cerr << macro_vi << " ";
  }
  cerr << "]" << endl;
  ;
  map<int, int> mp;
  for (int i = 0; i <= N; i++) {
    mp[L[i]]++;
  }
  int cnt = 0;
  for (auto p : mp) {
    int x, c;
    tie(x, c) = p;
    cerr << "("
            "x"
            ","
            "c"
            "):("
         << x << "," << c << ")" << endl;
    cnt += c * (c - 1) / 2;
  }
  cout << cnt << endl;
  return 0;
}
