#include <bits/stdc++.h>
using namespace std;
int dx[8] = {0, 0, -1, 1, 1, 1, -1, -1};
int dy[8] = {-1, 1, 0, 0, 1, -1, 1, -1};
const int SIZE = 100050;
int main() {
  int N;
  cin >> N;
  vector<int> A;
  A.push_back(0);
  for (int i = 0; i < N; i++) {
    int a;
    cin >> a;
    A.push_back(a);
  }
  for (int i = 1; i < N + 1; i++) A[i] += A[i - 1];
  sort(A.begin(), A.end());
  long long ans = 0;
  map<long long, long long> pam;
  for (int i = 0; i < N + 1; i++) pam[A[i]]++;
  for (pair<long long, long long> P : pam) {
    ans += P.second * (P.second - 1) / 2;
  }
  cout << ans << endl;
  return 0;
}
