#include <bits/stdc++.h>
template <class T>
bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
using namespace std;
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<int, int>;
const int inf = 1e9 + 7;
const ll inf_l = 1e18;
const int MAX = 1e6;
int main() {
  int n;
  cin >> n;
  vint a(n);
  for (int i = 0; i < (int)(n); i++) cin >> a[i];
  map<ll, int> mp;
  vll sum(n + 1, 0);
  for (int i = 0; i < (int)(n); i++) sum[i + 1] = sum[i] + a[i];
  for (int i = 0; i < (int)(n + 1); i++) mp[sum[i]]++;
  ll ans = 0;
  for (P p : mp) {
    ans += p.second * (p.second - 1) / 2;
  }
  cout << ans << endl;
}
