#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9;
int n, m, ans;
vector<int> a(200005);
vector<int> d(200005);
int main() {
  cin >> n;
  for (int i = 0; i < (n); i++) cin >> a[i];
  for (int i = 0; i < n; i++) d[i + 1] = d[i] + a[i];
  sort(d.begin(), d.begin() + (n + 1));
  int b = d[0], bkazu = 1;
  for (int i = 1; i <= n; i++) {
    if (b != d[i]) {
      ans += (bkazu * (bkazu - 1)) / 2;
      b = d[i];
      bkazu = 1;
    } else {
      bkazu++;
    }
  }
  ans += (bkazu * (bkazu - 1)) / 2;
  cout << ans << endl;
  return 0;
}
