#include <bits/stdc++.h>
const int inf = 2e9;
using namespace std;
long long MOD = 1000000007;
typedef struct {
  int a, b, c;
} iii;
void mosA(vector<int> a) {
  for (int i = 0; i < a.size(); i++) printf("%d ", a[i]);
  printf("\n");
}
void mosP(vector<pair<int, int> > a) {
  for (int i = 0; i < a.size(); i++) printf("%d %d\n", a[i].first, a[i].second);
  printf("\n");
}
bool ord(pair<int, int> a, pair<int, int> b) { return b.second < a.second; }
int ans = 0;
int k, a, b, minimo, ver, t, p, n, m;
int A[200005];
map<int, int> M;
int main() {
  scanf("%d", &n);
  for (int i = 0; i < (n); i++) scanf("%d", A + i);
  long long sum = 0;
  M[sum] = 1;
  for (int i = 0; i < (n); i++) {
    sum += A[i];
    if (M[sum])
      ans += M[sum], M[sum]++;
    else
      M[sum]++;
  }
  printf("%d\n", ans);
}
