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