#include <bits/stdc++.h>
using namespace std;
void _main();
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  _main();
}
using ll = long long;
constexpr int inf = INT_MAX / 2;
constexpr ll infl = 1LL << 60;
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;
}
class Solution {
 public:
  int solve(int N, vector<int> &A);
};
int Solution::solve(int N, vector<int> &A) {
  map<ll, int> m;
  ll sum = 0;
  ++m[sum];
  for (int i = (0); i < (N); ++i) {
    sum += A[i];
    ++m[sum];
  }
  ll ans = 0;
  for (auto &x : m) {
    ans += 1ll * x.second * (x.second - 1) / 2;
  }
  return ans;
}
void _main() {
  int N;
  cin >> N;
  vector<int> A(N);
  for (int i = (0); i < (N); ++i) cin >> A[i];
  Solution solution;
  ll ans = solution.solve(N, A);
  cout << ans << endl;
}
