#include <bits/stdc++.h>
using namespace std;
typedef vector<vector<int>> vii;
template <typename T>
using vec = vector<T>;
template <class T>
using maxheap = std::priority_queue<T>;
template <class T>
using minheap = std::priority_queue<T, std::vector<T>, std::greater<T>>;
template <class T, class U>
inline bool chmax(T &a, const U &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T, class U>
inline bool chmin(T &a, const U &b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
const long double Pi = std::acos(-1.0L);
const long long infll = (1LL << 62) - 1;
const int inf = (1 << 30) - 1;
const int mod = 1000000007;
signed main() {
  int _StartTime_ = clock();
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  vec<int> a(n);
  for (int i = 0; i < ((int)(n)); i++) cin >> a[i];
  vector<int> csum(n);
  csum[0] = a[0];
  for (int i = 1; i <= ((int)(n - 1)); i++) csum[i] = csum[i - 1] + a[i];
  sort((csum).begin(), (csum).end());
  csum.push_back(csum[n - 1] - 1);
  int ans = 0;
  int cnt = 1;
  for (int i = 0; i < n; ++i) {
    int j = i + 1;
    if (csum[i] == 0) ++ans;
    if (csum[i] == csum[j])
      ++cnt;
    else {
      ans += cnt * (cnt - 1) / 2;
      cnt = 1;
    }
  }
  cout << ans << '\n';
}
