#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using P = pair<int, int>;
using Tapris = tuple<int, int, int>;
const int INF = (int)1e9;
const LL INFL = (LL)1e15;
const int MOD = 1e9 + 7;
int dy[] = {0, 0, 1, -1, 0};
int dx[] = {1, -1, 0, 0, 0};
int n;
vector<int> a, ruiseki;
signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> n;
  a.assign(n, 0);
  ruiseki.assign(n + 1, 0);
  for (LL i = 0; i < n; ++i) cin >> a[i];
  for (LL i = 1; i < n + 1; ++i) {
    ruiseki[i] = ruiseki[i - 1] + a[i - 1];
  }
  map<int, int> mp;
  int ans = 0;
  for (LL i = 0; i < n + 1; ++i) {
    if (mp.count(ruiseki[i])) ans += mp[ruiseki[i]];
    mp[ruiseki[i]]++;
  }
  cout << ans << endl;
}
