#include <bits/stdc++.h>
using namespace std;
int N = 0;
int A[200020] = {0};
long long B[200020] = {0};
vector<pair<long long, int> > C;
set<long long> D;
void input() {
  cin >> N;
  for (int i = 0; i < N; i++) {
    cin >> A[i];
    B[i + 1] = B[i] + A[i];
  }
}
int memo[200020] = {0};
int calc(int n) {
  if (memo[n]) return memo[n];
  int ans = 0;
  for (int i = 1; i <= n; i++) memo[i] = memo[i - 1] + i;
  return memo[n];
}
int solve() {
  int ans = 0;
  for (int i = 0; i <= N; i++) {
    set<long long>::iterator ite = D.find(B[i]);
    if (ite == D.end()) {
      D.insert(B[i]);
      C.push_back(pair<long long, int>(B[i], 1));
    } else {
      int len = C.size();
      for (int j = 0; j < len; j++) {
        int temp = C[j].first;
        if (temp == B[i]) {
          C[j].second++;
          break;
        }
      }
    }
  }
  for (int i = 0, len = C.size(); i < len; i++) {
    int F = C[i].first;
    int S = C[i].second;
    if (S == 1)
      continue;
    else {
      ans += calc(S - 1);
    }
  }
  return ans;
}
int main() {
  input();
  printf("%d\n", solve());
  return 0;
}
