#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using P = pair<int, int>;
vector<int> bitSearch(int bit, int n) {
  vector<int> S;
  for (int i = 0; (i) < (int)(n); i++)
    if (bit & (1 << i)) S.push_back(i);
  return S;
}
int dy[2] = {1, 0};
int dx[2] = {0, 1};
int h, w;
vector<string> s(10);
int main() {
  int n;
  cin >> n;
  vector<ll> a(n);
  vector<ll> sum(n + 1);
  sum[0] = 0;
  for (int i = 0; (i) < (int)(n); i++) {
    cin >> a[i];
    sum[i + 1] = a[i] + sum[i];
  }
  map<ll, int> mp;
  for (int i = (int)(0); (i) <= (int)(n); i++) {
    mp[sum[i]]++;
  }
  ll res = 0;
  for (auto x : mp) {
    res += x.second * (x.second - 1) / 2;
  }
  cout << res << endl;
}
