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