#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 10;
int s[N];
int main() {
  int n;
  scanf("%d", &n);
  int x;
  for (int i = 1; i <= n; i++) {
    scanf("%d", &x);
    s[i] = s[i - 1] + x;
  }
  sort(s, s + n + 1);
  long long ans = 0, ll, num;
  for (int i = 0; i <= n;) {
    ll = s[i];
    num = 0;
    for (; i <= n && s[i] == ll; i++) num++;
    ans = ans + num * (num - 1) / 2;
  }
  printf("%lld\n", ans);
  return 0;
}
