#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e5 + 10;
long long a[MAXN], ans = 0;
map<long long, long long> mp;
map<long long, long long>::iterator iter;
int main() {
  int n;
  scanf("%d", &n);
  memset(a, 0, sizeof(a));
  for (int i = 1; i <= n; i++) {
    scanf("%I64d", &a[i]);
    a[i] += a[i - 1];
    mp[a[i]]++;
  }
  for (int i = 1; i <= n; i++)
    if (a[i] == 0) ans++;
  for (iter = mp.begin(); iter != mp.end(); iter++) {
    if (iter->second > 1) ans += iter->second * (iter->second - 1) / 2;
  }
  printf("%I64d\n", ans);
  return 0;
}
