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