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