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