#include <bits/stdc++.h>
using namespace std;
const int N = 200010;
int n;
int a[N];
long long pre[N];
unordered_map<int, int> f;
void readData() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
}
void solve() {
  for (int i = 1; i <= n; i++) pre[i] = pre[i - 1] + a[i];
  f[0] = 1;
  long long ans = 0;
  for (int i = 1; i <= n; i++) {
    ans += f[pre[i]];
    f[pre[i]]++;
  }
  printf("%lld\n", ans);
}
int main() {
  readData();
  solve();
  return 0;
}
