#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using P = pair<ll, ll>;
const int dx[] = {0, 1, -1, 0};
const int dy[] = {1, 0, 0, -1};
const ll mod = 1e9 + 7;
const ll INF = 1e9;
const ll LINF = 1LL << 60;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<int> a(n), s(n + 1, 0);
  for (int i = 0; i < (int)n; ++i) cin >> a[i];
  for (int i = 0; i < (int)n; ++i) s[i + 1] = s[i] + a[i];
  map<int, int> mp;
  for (int i = 0; i < (int)n + 1; ++i) mp[s[i]]++;
  ll ans = 0;
  for (auto x : mp) ans += x.second * (x.second - 1) / 2;
  cout << ans << endl;
  return 0;
}
