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