#include <bits/stdc++.h>
using namespace std;
long long num[100010], book[100010];
long long k;
int n;
int main() {
  long long sum, ans;
  int i;
  while (scanf("%d", &n) != EOF) {
    for (i = 1; i <= n; i++) {
      scanf("%I64d", &num[i]);
    }
    memset(book, 0, sizeof(book));
    sum = 0, ans = 0;
    for (i = 1; i <= n; i++) {
      sum += num[i];
      if (sum == 0) ans++;
      ans += book[sum];
      book[sum]++;
    }
    printf("%I64d\n", ans);
  }
  return 0;
}
