#include <bits/stdc++.h>
using namespace std;
inline int toInt(string s) {
  int x;
  istringstream iss(s);
  iss >> x;
  return x;
}
template <class T>
inline string toString(T x) {
  ostringstream oss;
  oss << x;
  return oss.str();
}
template <class T>
inline T sqr(T x) {
  return x * x;
}
const double EPS = 1e-10;
const double PI = acos(-1.0);
int main() {
  int n;
  scanf("%d", &n);
  vector<long long> a(n, 0), b(n, 0);
  for (int i = (0); i < (n); i++) {
    scanf("%ld", &a[i]);
    if (i == 0)
      b[i] = a[i];
    else
      b[i] = b[i - 1] + a[i];
  }
  b.push_back(0);
  sort((b).begin(), (b).end());
  int now = b[0];
  long long cnt = 1;
  long long res = 0;
  for (int i = (1); i < (n + 1); i++) {
    if (now == b[i])
      cnt++;
    else {
      res += cnt * (cnt - 1) / 2;
      now = b[i];
      cnt = 1;
    }
  }
  res += cnt * (cnt - 1) / 2;
  cout << res << endl;
  return 0;
}
