#include <bits/stdc++.h>
using namespace std;
const long long INF = 1LL << 60;
const long long MOD = 1000000000 + 7;
int main() {
  int n;
  long long a;
  cin >> n;
  vector<long long> cnt(n, 0);
  vector<long long> asum(n + 1, 0);
  for (int i = 0; i < (int)(n); i++) {
    cin >> a;
    cnt[i] = a;
  }
  for (int i = 0; i < (int)(n); i++) asum[i + 1] = asum[i] + cnt[i];
  map<long long, int> lap;
  for (int i = 0; i < (int)(n + 1); i++) lap[asum[i]]++;
  long long out = 0;
  for (auto itr = lap.begin(); itr != lap.end(); itr++) {
    out += itr->second * (itr->second - 1) / 2;
  }
  cout << out << endl;
  return 0;
}
