#include <bits/stdc++.h>
using namespace std;
using llong = long long;
using P = pair<llong, llong>;
const llong inf = llong(1e18) + 7;
const llong mod = 1e9 + 7;
int main() {
  llong N;
  vector<llong> A;
  map<llong, int> m;
  m[0]++;
  cin >> N;
  A.resize(N);
  llong sum = 0;
  for (int i = 0; i < N; i++) {
    cin >> A[i];
    sum += A[i];
    m[sum]++;
  }
  llong ans = 0;
  for (auto it = m.begin(); it != m.end(); it++) {
    ans += (it->second * it->second - it->second) / 2;
  }
  cout << ans << endl;
  return 0;
}
