#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9 + 6;
const long long MOD = 1e9 + 7;
const long long LLINF = 1LL << 60;
int main() {
  int N;
  cin >> N;
  int A[N];
  for (int i = 0; i < (int)(N); i++) cin >> A[i];
  long long sum[N + 1];
  map<long long, int> make_pair;
  sum[0] = 0;
  make_pair[0]++;
  for (int i = 0; i < (int)(N); i++)
    sum[i + 1] = sum[i] + A[i], make_pair[sum[i + 1]]++;
  long long ans = 0;
  for (auto i = make_pair.begin(); i != make_pair.end(); ++i) {
    ans += (i->second) * (i->second - 1) / 2;
  }
  cout << ans << endl;
}
