#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int a[n];
  for (int i = 0; i < n; i++) cin >> a[i];
  long long acc[n + 1];
  acc[0] = 0;
  for (int i = 0; i < n; i++) {
    acc[i + 1] = acc[i] + a[i];
  }
  map<int, long long> m;
  for (int i = 0; i < n + 1; i++) {
    ++m[acc[i]];
  }
  long long ans = 0;
  for (auto mi : m) {
    long long x = mi.second;
    ans += x * (x - 1) / 2;
  }
  cout << ans << endl;
}
