#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define FORR(i, a, b) for (int i = (int)(b)-1; i >= (int)(a); i--)

#define CHMIN(a, b) (a) = min((a), (b))
#define CHMAX(a, b) (a) = max((a), (b))

#define DEBUG(x) cout << #x << ": " << (x) << endl

//累積和　

int main() {
  int N;
  cin >> N;

  vl sum(N + 1, 0);
  map<ll, ll> num;

  FOR(i, 1, N + 1) {
    ll a;
    cin >> a;
    sum[i] = sum[i - 1] + a;
  }

  FOR(i, 0, N + 1) { num[sum[i]]++; }

  ll res = 0;
  for (auto it : nums) {
    long long num = it.second;  // it.first が it.second 個ある
    res += num * (num - 1) / 2;
  }

  cout << res << endl;
}