#include <bits/stdc++.h>
using namespace std;
inline bool isLow(char ch) {
  if (ch >= 'a' && ch <= 'z') return true;
  return false;
}
inline bool isUpp(char ch) {
  if (ch >= 'A' && ch <= 'Z') return true;
  return false;
}
inline bool isDig(char ch) {
  if (ch >= '0' && ch <= '9') return true;
  return false;
}
inline bool are_equal(double a, double b) {
  return fabs(a - b) < numeric_limits<double>::epsilon();
}
inline bool less_than(double a, double b) {
  return (b - a) > ((fabs(a) < fabs(b) ? fabs(b) : fabs(a)) *
                    numeric_limits<double>::epsilon());
}
inline bool greater_than(double a, double b) {
  return (a - b) > ((fabs(a) < fabs(b) ? fabs(b) : fabs(a)) *
                    numeric_limits<double>::epsilon());
}
template <typename T>
string toString(T x) {
  stringstream ss;
  ss << x;
  return ss.str();
}
template <typename T>
T stringToT(string s, T a) {
  T p;
  istringstream ss(s);
  ss >> p;
  return p;
}
template <typename T>
T SOD(T n) {
  __typeof(n) sum = 0, i = 1;
  for (; i * i <= n; i++)
    sum += (n % i) ? 0 : ((((i) * (i)) == n) ? i : i + n / i);
  return sum;
}
template <typename T, typename S>
ostream& operator<<(ostream& os, const pair<T, S>& v) {
  os << "(" << v.first << ", " << v.second << ")";
  return os;
}
template <typename T, typename S>
ostream& operator<<(ostream& os, const map<T, S>& v) {
  for (auto it : v) os << it.first << " : " << it.second << '\n';
  return os;
}
template <typename T>
ostream& operator<<(ostream& os, const set<T>& v) {
  os << "[";
  for (auto it : v) {
    os << it;
    if (it != *v.rbegin()) os << ", ";
  }
  os << "]";
  return os;
}
template <typename T>
ostream& operator<<(ostream& os, const vector<T>& v) {
  os << "[";
  for (int i = 0; i < v.size(); i++) {
    os << v[i];
    if (i != (int)v.size() - 1) os << ", ";
  }
  os << "]";
  return os;
}
const int mod = 1e9 + 7;
const int mx = 2 * 100001;
int n, x, a[mx];
vector<int> tree[mx << 2];
void merge(vector<int>& a, vector<int>& b, vector<int>& c) {
  int i = 0, j = 0;
  while (i < b.size() && j < c.size()) {
    if (b[i] <= c[j])
      a.push_back(b[i]), i++;
    else
      a.push_back(c[j]), j++;
  }
  while (i < b.size()) a.push_back(b[i++]);
  while (j < c.size()) a.push_back(c[j++]);
}
void build(int p, int l, int r) {
  if (l == r)
    tree[p].push_back(a[l]);
  else {
    build((p << 1), l, (l + r) / 2);
    build((p << 1) + 1, (l + r) / 2 + 1, r);
    merge(tree[p], tree[(p << 1)], tree[(p << 1) + 1]);
  }
}
int getAns(int p, int l, int r, int i, int j, int x) {
  if (i > r || j < l) return 0;
  if (l >= i && r <= j)
    return (upper_bound(tree[p].begin(), tree[p].end(), x)) -
           (lower_bound(tree[p].begin(), tree[p].end(), x));
  return getAns((p << 1), l, (l + r) / 2, i, j, x) +
         getAns((p << 1) + 1, (l + r) / 2 + 1, r, i, j, x);
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> n;
  for (__typeof(n) i = (1); i <= (n); i++) {
    cin >> x;
    a[i] = x + a[i - 1];
  }
  build(1, 1, n);
  long long ans = 0;
  for (__typeof(n) i = (1); i <= (n); i++)
    ans += getAns(1, 1, n, i, n, a[i - 1]);
  cout << ans << '\n';
  return 0;
}
