#include <bits/stdc++.h>
using namespace std;
const int inf = 1001001001;
const int mod = 1000000007;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < (n); ++i) cin >> a[i];
  vector<long long> sum(n + 1);
  for (int i = 0; i < (n); ++i) sum[i + 1] = sum[i] + a[i];
  map<long long, int> mp;
  for (int i = 0; i < (n + 1); ++i) mp[sum[i]]++;
  long long ans = 0;
  for (auto& c : mp) {
    ans += c.second * (c.second - 1) / 2;
  }
  cout << ans << endl;
  return 0;
}
