#include <bits/stdc++.h>
using namespace std;
template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
using ll = long long;
const vector<int> dx = {1, 0, -1, 0};
const vector<int> dy = {0, 1, 0, -1};
const ll inf = 1001001001;
const ll e9 = 1000000000;
const ll mod = 1000000007;
int main() {
  int n;
  cin >> n;
  vector<ll> sum(n + 1, 0);
  ll ans = 0;
  for (int i = 1; i < n + 1; ++i) {
    ll p;
    cin >> p;
    sum[i] = sum[i - 1] + p;
    if (sum[i] == 0) ans++;
  }
  sort(sum.begin(), sum.end());
  ll q = sum[1];
  int cnt = 1;
  for (int i = 2; i < n + 1; ++i) {
    if (sum[i] == q)
      cnt++;
    else {
      ans += (cnt - 1) * cnt / 2;
      cnt = 1;
      q = sum[i];
    }
  }
  ans += (cnt - 1) * cnt / 2;
  cout << ans << endl;
}
