#include <bits/stdc++.h>
using namespace std;
vector<long long> ans;
int a[200020];
int sum[200020] = {0};
int main() {
  long long n, ans1 = 0;
  long long co = 0;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    sum[i] = a[i] + sum[i - 1];
  }
  for (int j = 0; j < n; j++) {
    if (sum[j] == 0) {
      ans1++;
    } else {
      ans.emplace_back(sum[j]);
    }
  }
  sort(ans.begin(), ans.end());
  for (int k = 0; k < ans.size(); k++) {
    if (k == ans.size() - 1 || ans[k] != ans[k + 1]) {
      ans1 += co * co;
      co = 0;
    } else {
      co++;
    }
  }
  cout << ans1 << endl;
}
