#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 (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
const int mod = 1000000007;
int main() {
  int n;
  cin >> n;
  long long a[n];
  for (int i = int(0); i < int(n); ++i) cin >> a[i];
  long long sum[n + 1];
  memset(sum, 0, sizeof(sum));
  map<long long, int> x;
  x[0]++;
  for (int i = int(0); i < int(n); ++i) {
    sum[i + 1] = sum[i] + a[i];
    x[sum[i + 1]]++;
  }
  long long ans = 0;
  for (auto it = x.begin(); it != x.end(); ++it) {
    int tmp = it->second;
    ans += tmp * (tmp - 1) / 2;
  }
  cout << ans << endl;
}
