#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9;
const long double EPS = 1e-8;
int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  for (int i = 0; i < (int)(N); i++) cin >> A[i];
  vector<long long> cum(N + 1, 0);
  for (int i = 0; i < (int)(N); i++) cum[i + 1] = cum[i] + A[i];
  map<int, long long> mp;
  for (int i = 0; i < (int)(N + 1); i++) ++mp[cum[i]];
  long long ret = 0;
  for (auto x : mp) {
    ret += x.second * (x.second - 1) / 2;
  }
  cout << ret << endl;
  return 0;
}
