#include <bits/stdc++.h>
using namespace std;
int N;
long long A[200000];
long long cnt[200001];
int main() {
  scanf("%d", &N);
  for (int i = 0; i < N; i++) scanf("%lld", &A[i]);
  cnt[0] = 0;
  for (int i = 0; i < N; i++) cnt[i + 1] = cnt[i] + A[i];
  sort(cnt, cnt + N + 1);
  vector<long long> c(N + 1);
  for (int i = 0; i < N + 1; i++) c.push_back(cnt[i]);
  sort(c.begin(), c.end());
  c.erase(unique(c.begin(), c.end()), c.end());
  long long ans = 0;
  for (auto t : c) {
    int count =
        upper_bound(cnt, cnt + N + 1, t) - lower_bound(cnt, cnt + N + 1, t);
    ans += count * (count - 1) / 2;
  }
  cout << ans << endl;
  return 0;
}
