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