#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector<vi>;
int main() {
  int N;
  cin >> N;
  vi A(N);
  vi B(N + 1);
  for (int i = 0; i < (int)(N); i++) {
    cin >> A[i];
    B[i + 1] = B[i] + A[i];
  }
  map<int, int> m;
  for (int i = 0; i < (int)(N + 1); i++) {
    m[B[i]]++;
  }
  int ans = 0;
  for (auto p : m) {
    auto v = p.second;
    ans += v * (v - 1) / 2;
  }
  cout << ans << endl;
  return 0;
}
