#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  int A[200001];
  long long S[200001];
  cin >> N;
  for (int i = 1; i <= N; i++) cin >> A[i];
  S[0] = 0;
  for (int i = 1; i <= N; i++) S[i] = S[i - 1] + A[i];
  sort(S, S + N + 1);
  long long result = 0;
  long long cur = S[0];
  S[N + 1] = 777777777;
  int count = 1;
  for (int i = 1; i <= N + 1; i++) {
    if (cur == S[i])
      count++;
    else {
      result += count * (count - 1) / 2;
      cur = S[i];
      count = 1;
    }
  }
  cout << result << endl;
  return 0;
}
