#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9 + 7;
using LL = long long;
const LL LINF = 1e18;
using namespace std;
class Edge {
 public:
  int from, to, value;
  Edge(int a, int b, int c) {
    from = a;
    to = b;
    value = c;
  }
  Edge(int a, int b) {
    from = a;
    to = b;
  }
};
LL mass[10000000];
int main() {
  int(N);
  cin >> (N);
  vector<int> vec;
  for (int a = 0; a < (N); ++a) {
    int(b);
    cin >> (b);
    vec.push_back(b);
  }
  for (int a = 1; a < N + 1; a++) {
    mass[a] = mass[a - 1] + vec.at(a - 1);
  }
  map<LL, int> mp;
  for (int a = 0; a < N + 1; a++) {
    if (mp.find(mass[a]) == mp.end()) {
      mp[mass[a]] = 1;
    } else {
      mp[mass[a]]++;
    }
  }
  LL ans = 0;
  for (auto p : mp) {
    if (p.second == 1) continue;
    int N = p.second - 1;
    LL ins = 1;
    for (int a = N; a >= 1; a--) {
      ins *= a;
    }
    ans += ins;
  }
  cout << (ans) << endl;
  return 0;
}
