#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  vector<int> A(N + 1, 0);
  map<int, int> mp;
  mp[0]++;
  for (int i = 1; i <= N; i++) cin >> A[i], A[i] += A[i - 1], mp[A[i]]++;
  int ans = 0;
  for (auto p : mp) ans += p.second * (p.second - 1) / 2;
  cout << ans << endl;
}
