#include <bits/stdc++.h>
using namespace std;
int N;
int A[200005];
int A_sum[200005];
int main() {
  cin >> N;
  map<int, vector<int> > x;
  for (int i = 1; i <= N; i++) {
    cin >> A[i];
  }
  A_sum[0] = 0;
  for (int i = 1; i <= N; i++) {
    A_sum[i] = A_sum[i - 1] + A[i];
  }
  for (int i = 0; i <= N; i++) {
    vector<int> sums = x[A_sum[i]];
    sums.push_back(i);
    x[A_sum[i]] = sums;
  }
  int ans = 0;
  for (auto elem : x) {
    int y = (elem.second).size() - 1;
    ans += y * (y + 1) / 2;
  }
  cout << ans << endl;
}
