#include <bits/stdc++.h>
#pragma GCC optimize("Ofast,no-stack-protector")
#pragma GCC target("avx,tune=native")
using namespace std;
template <typename T>
using pq_gt = priority_queue<T, vector<T>, greater<T>>;
template <typename T>
using pq_lt = priority_queue<T, vector<T>, less<T>>;
int A[100100];
map<int, int> m;
int main() {
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  int a;
  int tmp = 0;
  m[0] = 1;
  long long int ans = 0;
  for (int i = 0; i < N; ++i) {
    cin >> a;
    tmp += a;
    ans += m[tmp];
    m[tmp]++;
  }
  cout << ans << endl;
}
