#include <bits/stdc++.h>
using namespace std;
long long gcd(long long a, long long b) { return b != 0 ? gcd(b, a % b) : a; }
long long lcm(long long a, long long b) { return a / gcd(a, b) * b; }
long long factorial(long long a) { return a < 2 ? 1 : factorial(a - 1) * a; }
long long summation(long long a) { return a < 1 ? 0 : (a * a + a) / 2; }
const long long INF = 1e16;
const long long MOD = 1e9 + 7;
const long long N = 200005;
const long long M = 100005;
const string ALPHABETS = "abcdefghijklmnopqrstuvwxyz";
long long dx[] = {-1, 0, 1, 0}, dy[] = {0, -1, 0, 1};
long long n, m, x, y, z, w, h;
string s, t;
signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  while (cin >> n) {
    long long ans = 0, tmp = 0, cnt = 0, mx = -INF, mn = INF;
    long long a[N] = {}, b[N] = {}, c[N] = {};
    vector<long long> v;
    v.push_back(0);
    for (long long i = long long(0); i < long long(n); i++) {
      cin >> x;
      v.push_back(v[v.size() - 1] + x);
    }
    sort(begin(v), end(v));
    v.push_back(0);
    for (long long i = long long(0); i < long long(v.size() - 1); i++) {
      if (v[i] == v[i + 1]) {
        cnt++;
      } else {
        ans += summation(cnt);
        cnt = 0;
      }
    }
    cout << (ans) << '\n';
  }
}
