#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  for (int i = 0; i < N; i++) cin >> A[i];
  vector<int> sum(N + 1);
  sum[0] = 0;
  for (int i = 1; i <= N; i++) sum[i] += sum[i - 1] + A[i - 1];
  map<int, int> m;
  ll ans = 0;
  m[0]++;
  for (int i = 1; i <= N; i++) {
    ans += m[sum[i]];
    m[sum[i]]++;
  }
  cout << ans << endl;
  return 0;
}
