#include <bits/stdc++.h>
using namespace std;
constexpr double EPS = 1e-9;
constexpr int INF = 1001001001;
constexpr int mod = 1000000007;
template <class T>
inline bool chmax(T& x, T y) {
  if (x < y) {
    x = y;
    return true;
  }
  return false;
}
template <class T>
inline bool chmin(T& x, T y) {
  if (x > y) {
    x = y;
    return true;
  }
  return false;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int n;
  cin >> n;
  vector<long long> S(n + 1);
  S[0] = 0;
  for (int i = 0; i < n; ++i) {
    cin >> S[i + 1];
    S[i + 1] += S[i];
  }
  long long ans = 0;
  map<int, int> mp;
  for (int i = 0; i <= n; ++i) {
    ans += mp[S[i]];
    ++mp[S[i]];
  }
  cout << ans << endl;
}
