#include <bits/stdc++.h>
using namespace std;
const int MAX_N = 200009;
int N, A[MAX_N];
long long s[MAX_N];
map<long long, int> M;
int main() {
  s[0] = 0;
  cin >> N;
  for (int i = 0; i < N; i++) {
    cin >> A[i];
    s[i + 1] = s[i] + A[i];
  }
  for (int i = 0; i <= N; i++) {
    M[s[i]]++;
  }
  long long ans = 0;
  for (auto it : M) {
    int n = it.second;
    ans += n * (n - 1) / 2;
  }
  cout << ans << endl;
  return 0;
}
