#include <bits/stdc++.h>
using namespace std;
const long long INF = 1e18;
const int inf = 1e9;
const int mod = 1e9 + 7;
const double EPS = (double)1e-9;
const double pi = acos(-1.0);
const int MAXN = 2e5 + 5;
int n, res;
long long a[MAXN], pref[MAXN];
unordered_map<long long, int> ct;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    pref[i] = pref[i - 1] + a[i];
  }
  ct[0] = 1;
  for (int i = 1; i <= n; i++) {
    res += ct[pref[i]];
    ct[pref[i]]++;
  }
  cout << res;
  return 0;
}
