#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  vector<long long> S;
  long long sum = 0;
  S.push_back(sum);
  int ret = 0;
  for (int i = 0; i < N; i++) {
    long long in;
    cin >> in;
    sum += in;
    S.push_back(sum);
  }
  sort(S.begin(), S.end());
  int i = 0;
  while (i < N + 1) {
    int init = i;
    long long s = S[i];
    while (i + 1 < N + 1 && S[i + 1] == s) {
      i++;
    }
    ret += ((i - init + 1) * (i - init) / 2);
    i++;
  }
  cout << ret << endl;
  return 0;
}
