#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;
ll mod = 1e9 + 7;
int main() {
  int n;
  cin >> n;
  vector<ll> A(n);
  for (int i = 0; i < (int)n; i++) {
    cin >> A[i];
  }
  vector<ll> B(n + 1);
  B[0] = 0;
  for (int i = 1; i <= n; i++) {
    B[i] = A[i - 1];
    B[i] += B[i - 1];
  }
  sort(B.begin(), B.end());
  vector<ll> ans;
  ll count = 1;
  for (int i = 0; i < (int)n + 1; i++) {
    if (B[i] == B[i + 1])
      count++;
    else {
      ans.push_back(count);
      count = 1;
    }
  }
  ll res = 0;
  for (int i = 0; i < (int)ans.size(); i++) {
    if (ans[i] % 2 == 0) {
      res += (ans[i] / 2) * (ans[i] - 1);
    } else {
      res += ((ans[i] - 1) / 2) * ans[i];
    }
  }
  cout << res << endl;
  return 0;
}
