#include <bits/stdc++.h>
using namespace std;
const double PI = 3.14159265358979323846;
const double EPS = 1e-9;
const long long INF = 10e17;
double equal(double a, double b) { return fabs(a - b) < DBL_EPSILON; }
std::istream &operator>>(std::istream &in, set<int> &o) {
  int 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(); }
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 sums.back();
    return sums[i];
  }
  long long getSectionSum(int start, int end) {
    return getSum(end) - getSum(start - 1);
  }
  void build() {
    for (int i = 0; i < numbers.size(); i++) {
      sums[i] = getSum(i - 1) + numbers[i];
    }
  }
};
int main() {
  int n;
  cin >> n;
  vector<long long> as(n);
  for (int i = 0; i < (n); ++i) cin >> as[i];
  CumulativeSum cs(n);
  for (int i = 0; i < (n); ++i) cs.set(i, as[i]);
  cs.build();
  multiset<long long> st;
  for (int i = 0; i < (n); ++i) st.insert(cs.getSum(i));
  long long ans = 0;
  for (int i = 0; i < (n); ++i) {
    long long target = as[i];
    long long now = st.count(cs.getSum(i) - target);
    ans += now;
    st.erase(st.find(cs.getSum(i)));
  }
  cout << ans << endl;
}
