#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9;
const int MOD = 1000000007;
int main() {
  int n;
  cin >> n;
  vector<int> a(n + 1, 0);
  for (int i = 1; i <= n; i++) cin >> a.at(i);
  for (int i = 0; i < n; i++) a.at(i + 1) += a.at(i);
  map<int, int> mp;
  for (int i = 0; i < n + 1; i++) mp[a.at(i)]++;
  long long ans = 0;
  for (auto p : mp) {
    ans += p.second * (p.second - 1) / 2;
  }
  cout << ans << endl;
  return 0;
}
