#include <bits/stdc++.h>
using namespace std;
template <class T>
void gi(T &x) {
  int f;
  char c;
  for (f = 1, c = getchar(); c < '0' || c > '9'; c = getchar())
    if (c == '-') f = -1;
  for (x = 0; c <= '9' && c >= '0'; c = getchar()) x = x * 10 + (c & 15);
  x *= f;
}
const int N = 2e5 + 10;
int n, a[N];
map<long long, int> t;
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) gi(a[i]);
  long long ans = 0;
  t[0] = 1;
  for (int i = 1; i <= n; i++) {
    a[i] += a[i - 1];
    if (t.find(a[i]) != t.end()) ans += t[a[i]];
    t[a[i]]++;
  }
  cout << ans << endl;
  return 0;
}
