#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
  int n, a;
  cin >> n;
  map<ll, int> mp;
  mp[0]++;
  ll sum = 0;
  for (int i = 0; i < n; i++) {
    scanf("%d", &a);
    sum += a;
    mp[sum]++;
  }
  int ans = 0;
  for (auto& m : mp) {
    if (m.second >= 2) ans += (m.second * (m.second - 1) / 2);
  }
  cout << ans << endl;
}
