#include <bits/stdc++.h>
using namespace std;
int main() {
  int N = 0;
  cin >> N;
  int temp;
  vector<int> A(N + 1, 0);
  for (int i = 0; i < N; i++) {
    cin >> temp;
    A.at(i + 1) = A.at(i) + temp;
  }
  vector<int> B(11118711, 0);
  for (int i = 0; i < N + 1; i++) {
    B.at(A.at(i) + 10000)++;
  }
  sort(B.begin(), B.end());
  reverse(B.begin(), B.end());
  int ans = 0;
  for (size_t i = 0; i < N; i++) {
    if (B.at(i) == 1) break;
    {}
    ans += B.at(i) * (B.at(i) - 1) / 2;
  }
  cout << ans << endl;
  return 0;
}
