#include <bits/stdc++.h>
using namespace std;
const long long int LINF = 2000000000000000000ll;
const int INF = 1000000100;
const long long int MOD = 1e9 + 7;
int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < (n); ++i) cin >> a[i];
  map<long long int, long long int, greater<long long int>> mp;
  vector<int> sum(n);
  sum[0] = a[0];
  mp[sum[0]]++;
  for (int i = 1; i < (n); ++i) {
    sum[i] = sum[i - 1] + a[i];
    mp[sum[i]]++;
  }
  long long int ans = 0;
  for (auto x : mp) {
    if (x.first == 0) ans += x.second;
    ans += (x.second * x.second - x.second) / 2;
  }
  cout << ans << endl;
  return 0;
}
