#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
void coY() { cout << "Yes" << endl; }
void coN() { cout << "No" << endl; }
const ll INF = 1LL << 60;
const int mod = 1e9 + 7;
int main() {
  int n;
  cin >> n;
  vector<ll> a(n);
  for (int i = (0); i < (n); ++i) cin >> a[i];
  vector<ll> b(n + 1);
  b[0] = 0;
  for (int i = (0); i < (n); ++i) {
    b[i + 1] = b[i] + a[i];
  }
  sort((b).begin(), (b).end());
  int now = b[0];
  int count = 1;
  ll ans = 0;
  for (int i = (0); i < (n); ++i) {
    if (now == b[i + 1]) {
      count++;
    } else {
      ans += (count * (count - 1)) / 2;
      count = 1;
      now = b[i + 1];
    }
  }
  ans += (count * (count - 1)) / 2;
  cout << ans << endl;
}
