#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int> >;
int main() {
  int N;
  cin >> N;
  vector<int> Input(N);
  for (int i = 0; i < N; i++) {
    cin >> Input[i];
  }
  for (int i = 1; i < N; i++) {
    Input[i] += Input[i - 1];
  }
  unordered_map<int, int> freq;
  freq[0] = 1;
  for (const auto &x : Input) {
    freq[x]++;
  }
  int ans = 0;
  for (const auto &x : freq) {
    ans += x.second * (x.second - 1) / 2;
  }
  cout << ans << endl;
}
