#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
const int maxn = 200000 + 5;
long long a[maxn];
map<long long, int> s;
set<long long> q;
int main() {
  int n;
  cin >> n;
  long long cnt = 0;
  s[0] = 1;
  for (int i = 1; i <= n; i++) {
    scanf("%lld", &a[i]);
    a[i] += a[i - 1];
    if (!s[a[i]])
      s[a[i]] = 1;
    else
      s[a[i]]++;
    if (!q.count(a[i])) q.insert(a[i]);
  }
  set<long long>::iterator it;
  for (it = q.begin(); it != q.end(); it++) {
    int k = s[*it];
    cnt += k * (k - 1) / 2;
  }
  printf("%lld\n", cnt);
  return 0;
}
