#include <bits/stdc++.h>
using namespace std;
const int INF = 1 << 29;
const double EPS = 1e-9;
const int dx[] = {1, 0, -1, 0, 1, 1, -1, -1},
          dy[] = {0, -1, 0, 1, 1, -1, -1, 1};
int main() {
  int N;
  cin >> N;
  vector<long long int> A(N);
  for (int i = 0; i < N; i++) {
    cin >> A[i];
  }
  vector<int> acc(N + 1, 0);
  long long int sum = 0;
  for (int i = 0; i < N; i++) {
    sum += A[i];
    acc[i + 1] = sum;
  }
  map<long long int, long long int> cnt;
  cnt[0]++;
  long long int ans = 0;
  for (int i = 0; i < N; i++) {
    long long int s1 = acc[i + 1];
    ans += cnt[s1];
    cnt[s1]++;
  }
  cout << ans << endl;
  return 0;
}
