#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 500;
map<int, int> a;
int main() {
  int n;
  while (~scanf("%d", &n)) {
    a.clear();
    long long x, sum = 0, ans = 0, t = 0, p = 0;
    for (int i = 0; i < n; i++) {
      scanf("%lld", &x);
      sum += x;
      ans += a[sum];
      if (sum == 0) ans++;
      a[sum]++;
    }
    cout << ans << endl;
  }
  return 0;
}
