#include <bits/stdc++.h>
using namespace std;
const int INF = INT_MAX;
const long long INFL = LONG_LONG_MAX;
const double PI = atan(1) * 4;
const int MOD = pow(10, 9) + 7;
int dy[] = {0, 0, 1, -1, 0};
int dx[] = {1, -1, 0, 0, 0};
template <typename T>
istream& operator>>(istream& is, vector<T>& vec) {
  for (T& x : vec) is >> x;
  return is;
}
template <typename T>
ostream& operator<<(ostream& os, vector<T>& vec) {
  for (int i = 0; i < vec.size(); i++) {
    os << vec[i] << (i + 1 == vec.size() ? "" : " ");
  }
  return os;
}
ll gcb(ll a, ll b) {
  if (b == 0) return a;
  return gcb(b, a % b);
}
ll lcm(ll a, ll b) { return a / gcb(a, b) * b; }
int getDigit(ll num) { return log10(abs(num)) + 1; }
int main() {
  int n;
  cin >> n;
  vector<int> A(n);
  cin >> A;
  map<ll, int> mp;
  mp[0]++;
  mp[A[0]]++;
  for (auto i = 1; i < n; i++) {
    A[i] += A[i - 1];
    mp[A[i]]++;
  }
  ll ans = 0;
  for (auto v : mp) {
    ans += ((v.second) * (v.second - 1)) / 2;
  }
  cout << ans << endl;
  return 0;
}
