#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  unordered_map<long long, int> mp;
  mp[0]++;
  long long pre = 0;
  for (int i = 0; i < N; ++i) {
    int x;
    cin >> x;
    pre += x;
    mp[pre]++;
  }
  long long cnt = 0;
  for (auto&& e : mp) cnt += e.second * (e.second - 1) / 2;
  cout << cnt << endl;
  return 0;
}
