#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  scanf("%d", &N);
  vector<int> A;
  vector<int> S;
  A.push_back(0);
  S.push_back(0);
  for (int i = 0; i < (N); ++i) {
    int x;
    scanf("%d", &x);
    A.push_back(x);
    S.push_back(x + S[i]);
  }
  sort(S.begin(), S.end());
  int count;
  vector<int> U;
  count = 1;
  for (int i = 0; i < (S.size() - 1); ++i) {
    if (S[i] == S[i + 1]) {
      count++;
    } else {
      U.push_back(count);
      count = 1;
    }
  }
  U.push_back(count);
  int ans = 0;
  for (int i = 0; i < (U.size()); ++i) {
    if (U[i] > 1) {
      ans += U[i] * (U[i] - 1) / 2;
    }
  }
  printf("%d\n", ans);
  return 0;
}
