#include <bits/stdc++.h>
using namespace std;
const int MAXN = 200050;
long long ans = 0;
int n, s[MAXN];
int main() {
  long long cnt = 1;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &s[i]);
    s[i] += s[i - 1];
  }
  sort(s, s + n + 1);
  for (int i = 0; i <= n + 1; i++) {
    if (i == 0 || i == n + 1 || s[i] != s[i - 1]) {
      ans += (long long)cnt * (cnt - 1) / 2LL;
      ;
      cnt = 1;
    } else if (s[i] == s[i - 1])
      cnt++;
  }
  printf("%lld", ans);
  fclose(stdin);
  fclose(stdout);
  return 0;
}
