#include <bits/stdc++.h>
using namespace std;
const int inf = 1e9;
const long long int linf = 1LL << 50;
const double EPS = 1e-10;
int main(int argc, char const* argv[]) {
  int n;
  vector<long long int> a;
  cin >> n;
  for (int i = 0; i < n; i++) {
    long long int x;
    cin >> x;
    if (i == 0)
      a.push_back(x);
    else
      a.push_back(a[i - 1] + x);
  }
  bool flag = false;
  if (a[0] == 0) flag = true;
  sort(a.begin(), a.end());
  long long int res = 0;
  long long int curr = 0;
  for (int i = 0; i < n; i++) {
    if (i == 0 || a[i] != a[i - 1]) {
      res += curr * (curr - 1) / 2;
      curr = 1;
    } else {
      curr++;
    }
  }
  int start = 0;
  while (a[start] == 0) start++;
  if (flag)
    res += 0;
  else
    res += start;
  res += curr * (curr - 1) / 2;
  cout << res << endl;
  return 0;
}
