#include <bits/stdc++.h>
using namespace std;
int main(void) {
  int n;
  scanf("%d", &n);
  vector<long long> a(n);
  for (int i = 0; i < n; i++) scanf("%lld", &a[i]);
  vector<long long> cum(n + 1, 0);
  for (int i = 0; i < n; i++) {
    cum[i + 1] = cum[i] + a[i];
  }
  map<long long, int> m;
  const long long M = 1e9 + 1;
  for (int i = 0; i < n + 1; ++i) {
    m[cum[i] + M]++;
  }
  long long ans = 0;
  for (auto i : m) {
    ans += (i.second - 1) * (i.second) / 2;
  }
  cout << ans << endl;
}
