#include <bits/stdc++.h>
using namespace std;
const long long MAX = 1e9;
int main() {
  int N;
  vector<long long> S(MAX, 0);
  map<long long, long long> nums;
  cin >> N;
  for (int i = 1; i <= N; i++) {
    int tmp;
    cin >> tmp;
    S.at(i) = tmp + S.at(i - 1);
  }
  for (int i = 1; i <= N; i++) {
    nums[S.at(i)]++;
  }
  long long ans{0};
  for (auto it : nums) {
    long long num = it.second;
    ans += num * (num - 1) / 2;
  }
  cout << ans << endl;
  return 0;
}
