#include <bits/stdc++.h>
using namespace std;
int n;
long long int a[200010];
long long int ans;
map<int, long long int> m;
int main() {
  cin >> n;
  a[0] = 0;
  for (int i = 0; i < n; ++i) cin >> a[i + 1];
  for (int i = 1; i < n + 1; ++i) a[i] += a[i - 1];
  for (int i = 0; i < n + 1; ++i) {
    auto it = m.find(a[i]);
    if (it != m.end()) {
      int val = it->second;
      ans += val;
      m[a[i]] = val + 1;
    } else {
      m.insert(pair<int, long long int>(a[i], 1));
    }
  }
  cout << ans << endl;
}
