#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll mod = 1e9 + 7;
int main() {
  int N;
  cin >> N;
  vector<int> vec(N);
  for (int i = 0; i < N; i++) {
    cin >> vec.at(i);
  }
  vector<int> count(N + 1);
  map<int, int> ma;
  count.at(0) = 0;
  for (int i = 0; i < N; i++) {
    count.at(i + 1) = count.at(i) + vec.at(i);
  }
  for (int i = 0; i < N + 1; i++) {
    ma[count.at(i)]++;
  }
  int answer = 0;
  for (auto x : ma) {
    auto value = x.second;
    answer += value * (value - 1) / 2;
  }
  cout << answer << endl;
}
