#include <bits/stdc++.h>
const double PI = 3.14159265358979323846;
using namespace std;
const double EPS = 1e-9;
const long long INF = 1e15;
std::istream &operator>>(std::istream &in, set<int> &o) {
  long long a;
  in >> a;
  o.insert(a);
  return in;
}
std::istream &operator>>(std::istream &in, queue<int> &o) {
  long long a;
  in >> a;
  o.push(a);
  return in;
}
bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }
const int mod = 1000000007;
typedef priority_queue<long long, vector<long long>, greater<long long> >
    PQ_ASK;
class CumulativeSum {
  vector<long long> numbers;
  vector<long long> sums;

 public:
  CumulativeSum(int n) {
    numbers.resize(n);
    sums.resize(n);
  }
  void set(int i, long long value) { numbers[i] = value; }
  long long getSum(int i) {
    if (i == -1) return 0;
    if (i == sums.size()) return 0;
    return sums[i];
  }
  long long getSectionSum(int start, int end) {
    return getSum(end) - getSum(start - 1);
  }
  void calculate() {
    for (int i = 0; i < numbers.size(); i++) {
      sums[i] = getSum(i - 1) + numbers[i];
    }
  }
};
int main() {
  int n;
  cin >> n;
  CumulativeSum cs(n);
  for (int i = 0; i < (n); ++i) {
    int a;
    cin >> a;
    cs.set(i, a);
  }
  cs.calculate();
  map<long long, int> m;
  m[0] = 1;
  for (int i = 0; i < (n); ++i) m[cs.getSum(i)]++;
  long long ans = 0;
  for (auto e : m) {
    ans += (e.second * (e.second - 1)) / 2;
  }
  cout << ans << endl;
}
