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