#include <bits/stdc++.h>
using namespace std;
const static long long int MOD = 1000000000 + 7;
const static int dy[] = {0, 1, 0, -1};
const static int dx[] = {1, 0, -1, 0};
int main(int argc, char *argv[]) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  vector<long long int> A;
  A.push_back(0);
  for (int i = 0; i < n; ++i) {
    int a;
    cin >> a;
    A.push_back(A[i] + a);
  }
  sort(A.begin(), A.end());
  map<int, int> M;
  for (int i = 0; i < n + 1; ++i) {
    ++M[A[i]];
  }
  long long int ans = 0;
  for (auto itr = M.begin(); itr != M.end(); ++itr) {
    ans += itr->second * (itr->second - 1) / 2;
  }
  cout << ans << endl;
  return 0;
}
