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