#include <bits/stdc++.h>
using namespace std;
int main(void) {
  int N;
  cin >> N;
  vector<int> A(N);
  for (int i = 0; i < (N); ++i) {
    cin >> A[i];
  }
  vector<int> SUM(N + 1);
  SUM[0] = 0;
  for (int i = 0; i < (N); ++i) {
    SUM[i + 1] = SUM[i] + A[i];
  }
  unordered_map<int, int> hist;
  int64_t answer = 0;
  for (int i = 0; i < (N); ++i) {
    answer += (int64_t)hist[SUM[i + 1]];
    hist[SUM[i + 1]]++;
  }
  answer += hist[0];
  cout << answer << endl;
  return 0;
}
