#include <bits/stdc++.h>
using namespace std;
using LL = long long;
int main() {
  int N;
  cin >> N;
  vector<LL> vec;
  vector<LL> ruiseki;
  ruiseki.push_back(0);
  for (int a = 0; a < N; a++) {
    LL b;
    cin >> b;
    ruiseki.push_back(ruiseki.back() + b);
  }
  map<LL, int> mp;
  for (int a = 0; a < ruiseki.size(); a++) {
    mp[ruiseki.at(a)]++;
  }
  LL ans = 0;
  for (auto a : mp) ans += a.second * (a.second - 1);
  cout << ans / 2 << endl;
}
