#include <bits/stdc++.h>
using namespace std;
const long long int MAX_N = 200000;
int main(int argc, char const *argv[]) {
  int N;
  cin >> N;
  int A[MAX_N], S[MAX_N + 1];
  long long int ans = 0;
  S[0] = 0;
  for (long long int i = 0; i < N; i++) cin >> A[i];
  for (size_t i = 1; i < N + 1; i++) S[i] = S[i - 1] + A[i - 1];
  sort(S, S + N + 1);
  long long int current = S[0];
  long long int cnt = 1;
  vector<long long int> cntvec;
  for (size_t i = 1; i < N + 1; i++) {
    if (S[i] != current) {
      current = S[i];
      if (cnt != 1) cntvec.push_back(cnt);
      cnt = 1;
    } else
      cnt++;
  }
  if (cnt != 1) cntvec.push_back(cnt);
  for (size_t i = 0; i < cntvec.size(); i++) {
    ans += (cntvec[i] * (cntvec[i] - 1)) / 2;
  }
  cout << ans << endl;
  return 0;
}
