#include <bits/stdc++.h>
using namespace std;
template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
const long long INF = 1LL << 60;
int main() {
  int N;
  cin >> N;
  vector<int> A(N), S(N + 1, 0);
  map<long long, long long> cnt;
  cnt[0] = 1;
  for (int i = (0); i < (N); i++) {
    cin >> A[i];
    S[i + 1] = S[i] + A[i];
    if (cnt.count(S[i + 1]) == 0) {
      cnt[S[i + 1]] = 1;
    } else {
      cnt[S[i + 1]]++;
    }
  }
  long long res = 0;
  for (auto itr = cnt.begin(); itr != cnt.end(); itr++) {
    res += (itr->second * (itr->second - 1)) / 2LL;
  }
  cout << res << endl;
  return 0;
}
