#include <bits/stdc++.h>
using namespace std;
int chh;
const int N = 200005;
int n;
int a[N];
map<int, int> q;
int main() {
  int tmp, ans, d;
  while (~scanf("%d", &n)) {
    tmp = 0, ans = 0;
    q.clear();
    for (int i = 0; i < (n); i++) {
      scanf("%d", &a[i]);
      q[tmp += a[i]]++;
    }
    d = 0;
    for (int i = 0; i < (n); i++) {
      ans += q[d];
      d += a[i];
      q[d]--;
    }
    printf("%d\n", ans);
  }
  return 0;
}
