#include <bits/stdc++.h>
template <typename T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
template <typename T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
using namespace std;
const long long MOD = 1e9 + 7;
template <typename T>
inline void add(T& a, T b) {
  a += b;
  if (a >= MOD) a -= MOD;
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  vector<long long> A(N + 1);
  A[0] = 0;
  map<int, int> T;
  T[0] = 1;
  for (int i = 1; i <= N; ++i) {
    cin >> A[i];
    A[i] += A[i - 1];
    T[A[i]]++;
  }
  long long ans = 0;
  for (auto t : T) {
    if (t.second >= 2) {
      ans += t.second * (t.second - 1) / 2;
    }
  }
  cout << ans << endl;
}
