#include <bits/stdc++.h>
using namespace std;
const double pi =
    3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342;
const int mod = 1000000007;
int main() {
  long long n, a[201010] = {}, s[201010] = {};
  long long c = 0;
  map<int, int> mp;
  cin >> n;
  for (int i = (0); i < (n); ++i) cin >> a[i];
  if (n == 1) {
  }
  s[0] = a[0];
  for (int i = (1); i < (n); ++i) s[i] += s[i - 1] + a[i];
  for (int i = (n)-1; i >= (0); --i) mp[s[i]]++;
  mp[0]++;
  for (auto x : mp) {
    long long t = x.second * 1LL;
    c += t * (t - 1) / 2;
  }
  cout << c << endl;
  return 0;
}
