#include <bits/stdc++.h>
using namespace std;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  vector<int> A(n);
  for (int i = 0; i < n; i++) cin >> A[i];
  unordered_map<int, int> mp;
  vector<int> B(n + 1);
  B[0] = 0;
  mp[0]++;
  for (int i = 0; i < n; i++) {
    if (i > 0)
      B[i + 1] += B[i] + A[i];
    else
      B[i + 1] = A[i];
    mp[B[i + 1]]++;
  }
  int ans = 0;
  for (auto x : mp) {
    ans += x.second * (x.second - 1) / 2;
  }
  cout << ans << endl;
  return 0;
}
