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