#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  vector<int> a(N);
  for (int i = 0; i < N; ++i) cin >> a[i];
  vector<int> s(N + 1, 0);
  map<int, int> nums;
  for (int i = 0; i < N; ++i) s[i + 1] = s[i] + a[i];
  for (int i = 0; i < N + 1; ++i) ++nums[s[i]];
  int res = 0;
  for (auto i : nums) {
    int num = i.second;
    res += num * (num - 1) / 2;
  }
  cout << res << endl;
}
