#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9;
const int mod = 1e9 + 7;
const double EPS = 1e-10;
const double PI = acos(-1.0);
int main() {
  int n;
  cin >> n;
  map<long long, int> mp;
  mp.emplace(0, 1);
  int ans = 0;
  vector<long long> a(n + 10, 0);
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    a[i] += a[i - 1];
    ans += mp[a[i]];
    mp[a[i]]++;
  }
  cout << ans << endl;
  return 0;
}
