#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;
}
long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }
const long long INF = 1LL << 60;
int main() {
  long long n;
  cin >> n;
  vector<long long> a(n);
  long long ans = 0;
  long long sum = 0;
  map<long long, long long> nums;
  ++nums[0];
  for (long long i = 0, i_len = (n); i < i_len; ++i) {
    cin >> a[i];
  }
  for (long long i = 0; i < n; ++i) {
    sum += a[i];
    ++nums[sum];
  }
  for (long long i = 0; i < n + 1; ++i) {
    ans += nums[i] * (nums[i] - 1) / 2;
  }
  cout << ans << endl;
}
