#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; ++i) cin >> a[i];
  vector<long long> s(n + 1, 0);
  for (int i = 0; i < n; ++i) s[i + 1] = s[i] + a[i];
  sort(s.begin(), s.end());
  long long num = 1;
  long long res = 0;
  for (int i = 0; i < n + 1; ++i) {
    if (s[i] == s[i + 1])
      ++num;
    else {
      res += num * (num - 1) / 2;
      num = 1;
    }
  }
  res += num * (num - 1) / 2;
  cout << res << endl;
}
