#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};
inline int sign(long long x) {
  if (x > 0) return 1;
  if (x < 0) return -1;
  return 0;
}
int main() {
  int N;
  cin >> N;
  vector<long long> A(N);
  for (int i = 0; i < N; i++) {
    cin >> A[i];
  }
  vector<long long> acc(N + 1);
  for (int i = 0; i < N; i++) {
    acc[i + 1] = acc[i] + A[i];
  }
  map<int, int> cnt;
  long long ans = 0;
  for (int i = 0; i < N + 1; i++) {
    ans += cnt[acc[i]];
    cnt[acc[i]]++;
  }
  cout << ans << endl;
  return 0;
}
