#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 10;
map<long long, int> rec;
int n, a[maxn];
long long s, ans;
int main() {
  scanf("%d", &n);
  rec[0] = 1;
  ans = 0ll;
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    s += (long long)a[i];
    ans += (long long)rec[s];
    rec[s]++;
  }
  printf("%d\n", ans);
  return 0;
}
