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