#include <bits/stdc++.h>
using namespace std;
template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
const int INF = 1e9;
const long long INFLL = 1e18;
const long long MOD = 1e9 + 7;
const double PI = acos(-1.0);
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
template <typename T>
vector<T> cumulative_sum(vector<T>& v) {
  vector<T> sum(v.size() + 1);
  for (int i = 0; i < (int)v.size(); ++i) {
    sum[i + 1] = sum[i] + v[i];
  }
  return sum;
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(20);
  int N;
  cin >> N;
  vector<long long> A(N);
  for (int i = 0; i < int(N); ++i) cin >> A[i];
  auto cumsum = cumulative_sum(A);
  map<long long, int> map;
  for (int i = 0; i < int((int)cumsum.size()); ++i) {
    map[cumsum[i]]++;
  }
  long long ans = 0;
  for (auto p : map) {
    ans += p.second * (p.second - 1) / 2;
  }
  cout << ans << endl;
}
