#include <bits/stdc++.h>
using namespace std;
const int inf = 0x3f3f3f3f;
const int maxn = 200007;
long long n, m, a[maxn], pre[maxn], res;
unordered_map<long long, int> num;
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%lld", &a[i]);
    pre[i] = pre[i - 1] + a[i];
    num[pre[i]]++;
  }
  num[0]++;
  for (unordered_map<long long, int>::iterator it = num.begin();
       it != num.end(); it++) {
    int p = it->second;
    res += p * (p - 1) >> 1;
  }
  cout << res << '\n';
  return 0;
}
