#include <bits/stdc++.h>
using namespace std;
template <typename T>
istream &operator>>(istream &is, vector<T> &vec) {
  for (T &x : vec) is >> x;
  return is;
}
long long int gcd(long long int m, long long int n) {
  if ((0 == m) || (0 == n)) return 0;
  while (m != n) {
    if (m > n)
      m = m - n;
    else
      n = n - m;
  }
  return m;
}
long long int lcm(long long int m, long long int n) {
  if ((0 == m) || (0 == n)) return 0;
  return ((m / gcd(m, n)) * n);
}
int ctoi(const char c) {
  if ('0' <= c && c <= '9') return (c - '0');
  return -1;
}
int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  for (int i = 0, i_len = (N); i < i_len; ++i) {
    cin >> A[i];
  }
  vector<int> S(N + 1);
  S[0] = 0;
  for (int i = (1); i < (N + 1); ++i) {
    S[i] = S[i - 1] + A[i - 1];
  }
  sort(S.begin(), S.end());
  int ans = 0, count = 0;
  for (int i = 0, i_len = (N); i < i_len; ++i) {
    if (S[i] == S[i + 1]) {
      if (count == 0) {
        count = 1;
      }
      count++;
    } else {
      ans += count * (count - 1) / 2;
      count = 0;
    }
  }
  ans += count * (count - 1) / 2;
  cout << ans << endl;
  return 0;
}
