#include <bits/stdc++.h>
const long long MXN = 2e5 + 1;
const long long MNN = 1 * 1e4 + 1;
const long long MOD = 1e8;
const long long INF = 1e18;
const long long OO = 1e9 + 500;
using namespace std;
int n, a[MXN], pref[MXN], ans;
map<long long, int> mp;
int main() {
  cin >> n;
  mp[0] = 1;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    pref[i] = pref[i - 1] + a[i];
    ans += mp[pref[i]];
    mp[pref[i]]++;
  }
  cout << ans;
  return 0;
}
