#include <bits/stdc++.h>
using namespace std;
long long INFL = 1000000000000000010;
int INF = 2000000000;
long long MOD = 998244353;
int N;
vector<long long> A(200010);
vector<long long> W(200010, -INFL);
int main() {
  cin >> N;
  W.at(0) = 0;
  for (int i = 0; i < N; i++) {
    cin >> A.at(i);
    W.at(i + 1) = W.at(i) + A.at(i);
  }
  W.at(N + 1) = INFL;
  sort(W.begin(), W.end());
  vector<int> cnt(0);
  int pre, now;
  now = -INFL;
  int l = 1;
  for (int i = 1; i < 200010; i++) {
    pre = now;
    now = W.at(i);
    if (pre == now) {
      l++;
    } else {
      cnt.push_back(l);
      l = 1;
    }
  }
  long long ans = 0;
  for (int i = 1; i < cnt.size(); i++) {
    ans += cnt.at(i) * (cnt.at(i) - 1) / 2;
  }
  cout << ans << endl;
}
