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