#include <bits/stdc++.h>
using namespace std;
void init(int n);
int find(int n);
void unite(int x, int y);
bool same(int x, int y);
long long int bpow(long long int, long long int, long long int);
vector<vector<int> > mul(vector<vector<int> > &A, vector<vector<int> > &B);
vector<vector<int> > pow(vector<vector<int> > A, long long int n);
int dx[4] = {1, 0, 0, -1};
int dy[4] = {0, 1, -1, 0};
const int MOD = 1000000007;
bool cmp_P(const pair<long long int, long long int> &a,
           const pair<long long int, long long int> &b) {
  return a.second < b.second;
}
int main() {
  int N, A[200001], sum[200002], res;
  cin >> N;
  for (int i = 0; i < (int)(N); i++) cin >> A[i];
  map<long long int, long long int> mp;
  sum[0] = 0;
  mp[0]++;
  for (int i = 0; i < (int)(N); i++) {
    sum[i + 1] = sum[i] + A[i];
    res += mp[sum[i + 1]];
    mp[sum[i + 1]]++;
  }
  cout << res << endl;
  return 0;
}
int par[100001];
int ranks[100001];
void init(int n) {
  for (int i = 0; i < (int)(n); i++) {
    par[i] = i;
    ranks[i] = 0;
  }
}
int find(int x) {
  if (par[x] == x) {
    return x;
  } else {
    return par[x] = find(par[x]);
  }
}
void unite(int x, int y) {
  x = find(x);
  y = find(y);
  if (x == y) return;
  if (ranks[x] < ranks[y]) {
    par[x] = y;
  } else {
    par[y] = x;
    if (ranks[x] == ranks[y]) ranks[x]++;
  }
}
bool same(int x, int y) { return find(x) == find(y); }
long long int bpow(long long int a, long long int n, long long int mod) {
  int i = 0;
  long long int res = 1;
  while (n) {
    if (n & 1) res = (res * a) % mod;
    a = (a * a) % mod;
    n >>= 1;
  }
  return res;
}
vector<vector<int> > mul(vector<vector<int> > &A, vector<vector<int> > &B) {
  vector<vector<int> > C(A.size(), vector<int>(B[0].size()));
  for (int i = 0; i < (int)(A.size()); i++)
    for (int k = 0; k < (int)(B.size()); k++)
      for (int j = 0; j < (int)(B[0].size()); j++) {
        C[i][j] = (C[i][j] + A[i][k] * B[k][j]) % MOD;
      }
  return C;
}
vector<vector<int> > pow(vector<vector<int> > A, long long int n) {
  vector<vector<int> > B(A.size(), vector<int>(A.size()));
  for (int i = 0; i < (int)(A.size()); i++) {
    B[i][i] = 1;
  }
  while (n > 0) {
    if (n & 1) B = mul(B, A);
    A = mul(A, A);
    n >>= 1;
  }
  return B;
}
