#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1000000007LL;
const int INF = 1000000007;
int N;
long long A[200002];
long long B[200002];
unordered_map<long long, int> Mp;
int main() {
  cin.sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> N;
  for (int i = 0; i < N; ++i) cin >> A[i];
  int cnt = 0;
  B[0] = A[0];
  for (int i = 0; i < N - 1; ++i) B[i + 1] = B[i] + A[i + 1];
  for (int i = 0; i < N; ++i) Mp[B[i]]++;
  int ans = 0;
  for (auto it = Mp.begin(); it != Mp.end(); ++it) {
    int v = it->first;
    int cnt = it->second;
    if (v == 0) ans += cnt;
    ans += cnt * (cnt - 1) / 2;
  }
  cout << ans << "\n";
  return 0;
}
