#include <bits/stdc++.h>
using namespace std;
using P = pair<int, int>;
template <class T>
bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <class T>
bool chmin(T &a, const T &b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
int main() {
  int n;
  cin >> n;
  vector<long long> a(n);
  for (int i = 0; i < (int)(n); i++) cin >> a[i];
  vector<long long> sum(n + 1);
  for (int i = 0; i < (int)(n); i++) sum[i + 1] = sum[i] + a[i];
  map<long long, int> mp;
  for (int i = 0; i < (int)(n + 1); i++) mp[sum[i]]++;
  long long ans = 0;
  for (auto m : mp) {
    ans += (m.second * (m.second - 1)) / 2;
  }
  cout << ans << endl;
  return 0;
}
