#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<long long> a(n);
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
  }
  vector<long long> sum(n + 1);
  for (int i = 1; i <= n; ++i) {
    sum[i] = sum[i - 1] + a[i - 1];
  }
  map<long long, int> mp;
  for (long long i : sum) mp[i]++;
  long long ans = 0;
  for (auto i : mp)
    if (i.second >= 2) ans += i.second * (i.second - 1) / 2;
  cout << ans << endl;
}
