#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
long long MOD = 1000000000 + 7;
constexpr long long INF = std::numeric_limits<LL>::max();
const double PI = acos(-1);
struct Tll {
  LL first, second, third;
};
LL h, w, n, m, k, s, t, q, last, cnt, ans, a[400000];
pair<LL, LL> sum[400000], flag[400000];
string str, ss;
bool f;
char c;
int di[4][2] = {{0, 1}, {1, 0}, {-1, 0}, {0, -1}};
struct Edge {
  LL to, cost;
};
vector<Edge> vec[10000];
set<LL> st;
void YN(bool f) {
  if (f)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
}
void yn(bool f) {
  if (f)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}
struct Combination {
  int mod;
  vector<int64_t> mfact, rfact;
  Combination(int sz, int mod) : mfact(sz + 1), rfact(sz + 1), mod(mod) {
    mfact[0] = 1;
    for (int i = 1; i < mfact.size(); i++) {
      mfact[i] = mfact[i - 1] * i % mod;
    }
    rfact[sz] = inv(mfact[sz]);
    for (int i = sz - 1; i >= 0; i--) {
      rfact[i] = rfact[i + 1] * (i + 1) % mod;
    }
  }
  int64_t fact(int k) const { return (mfact[k]); }
  int64_t pow(int64_t x, int64_t n) const {
    int64_t ret = 1;
    while (n > 0) {
      if (n & 1) (ret *= x) %= mod;
      (x *= x) %= mod;
      n >>= 1;
    }
    return (ret);
  }
  int64_t inv(int64_t x) const { return (pow(x, mod - 2)); }
  int64_t P(int n, int r) const {
    if (r < 0 || n < r) return (0);
    return (mfact[n] * rfact[n - r] % mod);
  }
  int64_t C(int p, int q) const {
    if (q < 0 || p < q) return (0);
    return (mfact[p] * rfact[q] % mod * rfact[p - q] % mod);
  }
  int64_t H(int n, int r) const {
    if (n < 0 || r < 0) return (0);
    return (r == 0 ? 1 : C(n + r - 1, r));
  }
};
int main() {
  cin >> n;
  Combination comb(201000, MOD);
  for (LL i = 0; i < n; i++) {
    cin >> a[i];
    sum[i + 1].first += sum[i].first + a[i];
    sum[i + 1].second = i + 1;
  }
  sort(sum, sum + n + 1);
  LL sz = 0;
  for (LL i = 0; i < n + 1; i++) {
    if (sum[i].first == flag[sz].first) {
      flag[sz].second++;
    } else {
      sz++;
      flag[sz].second++;
      flag[sz].first = sum[i].first;
    }
  }
  for (LL i = 0; i < sz + 1; i++) {
    ans += comb.C(flag[i].second, 2);
  }
  cout << ans << endl;
  return 0;
}
