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