#include <bits/stdc++.h>
using namespace std;
template <class T>
bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
bool chmin(T &a, const T &b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
const long long MOD = 1e9 + 7;
long long comb(long long a, long long b) {
  if (b == 0 || a == b)
    return 1;
  else
    return comb(a - 1, b) + comb(a - 1, b - 1);
}
int main() {
  int N;
  cin >> N;
  vector<long long> S(N + 1);
  S[0] = 0;
  for (int i = 0; i < N; i++) {
    long long a;
    cin >> a;
    S[i + 1] = a;
    S[i + 1] += S[i];
  }
  map<long long, int> ma;
  for (auto &&s : S) {
    ma[s]++;
  }
  long long ans = 0;
  for (auto &&p : ma) {
    int cnt = p.second;
    if (cnt <= 1) continue;
    ans += comb(cnt, 2);
  }
  cout << ans << endl;
  return 0;
}
