#include <bits/stdc++.h>
using namespace std;
inline long long read() {
  long long f = 1, sum = 0;
  char c = getchar();
  while (c < '0' || c > '9') {
    if (c == '-') f = -1;
    c = getchar();
  }
  while (c >= '0' && c <= '9') {
    sum = sum * 10 + c - '0';
    c = getchar();
  }
  return sum * f;
}
const int MAXN = 200010;
int a[MAXN];
long long s[MAXN];
map<long long, int> num;
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]), s[i] = s[i - 1] + a[i];
  for (int i = 1; i <= n; i++) num[s[i]]++;
  int ans = num[0];
  long long tmp = 0;
  for (int i = 1; i <= n; i++) {
    tmp += a[i];
    num[s[i]]--;
    ans += num[tmp];
  }
  cout << ans;
  return 0;
}
