#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1e9 + 7;
int main() {
  long long n;
  cin >> n;
  vector<long long> a(n);
  for (long long i = 0; i < n; i++) {
    cin >> a[i];
  }
  for (long long i = 1; i < n; i++) {
    a[i] += a[i - 1];
  }
  map<long long, long long> data;
  for (long long i = 0; i < n; i++) {
    data[a[i]]++;
  }
  long long ans = 0;
  for (auto it : data) {
    long long num = it.second;
    ans += num * (num - 1) / 2;
  }
  cout << ans << endl;
}
