#include <bits/stdc++.h>
using namespace std;
const int inf = 1e9 + 7;
const long long longinf = 1LL << 60;
const int mx = 1000010;
const long long mod = 1e9 + 7;
int main() {
  int n;
  cin >> n;
  vector<long long> a(n);
  for (int i = (int)(0); i < (int)(n); ++i) cin >> a[i];
  vector<long long> r(n + 1, 0);
  for (int i = (int)(0); i < (int)(n); ++i) r[i + 1] = r[i] + a[i];
  map<long long, int> mp;
  long long ans = 0;
  for (int i = (int)(0); i < (int)(n + 1); ++i) {
    mp[r[i]]++;
  }
  for (auto it : mp)
    if (it.second != 1) {
      ans += it.second * (it.second - 1) / 2;
    }
  cout << ans << endl;
  return 0;
}
