#include <bits/stdc++.h>
using namespace std;
int n;
map<int, int> vis;
int a[200005];
long long psa[200005];
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    psa[i] = psa[i - 1] + a[i];
  }
  long long ans = 0LL;
  vis[0] = 1;
  for (int i = 1; i <= n; i++) {
    ans += vis[psa[i]];
    vis[psa[i]]++;
  }
  printf("%lld\n", ans);
  return 0;
}
