#include <bits/stdc++.h>
using namespace std;
long long gcd(long long, long long);
vector<bool> to_binary(int);
int sum(vector<int>);
int min(vector<int>);
int max(vector<int>);
long long nCr(long long n, long long r);
int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  vector<int> A(N);
  for (long long i = 0; i < (long long)N; i++) cin >> A[i];
  vector<int> Sum(N + 1);
  int tmp = 0;
  for (long long i = 0; i < (long long)N; i++) {
    Sum[i] = tmp;
    tmp += A[i];
  }
  Sum[N] = tmp;
  sort(Sum.begin(), Sum.end());
  int ans = 0;
  int ind = 0;
  tmp = Sum[0];
  for (int i = 1; i < N + 2; i++) {
    if (i == N + 1) {
      ans += nCr(i - ind, 2);
      break;
    }
    if (Sum[i] != tmp) {
      ans += nCr(i - ind, 2);
      ind = i;
      tmp = Sum[i];
    }
  }
  cout << ans << endl;
ProgramEndPointLabel:;
  system("pause");
  return 0;
}
long long nCr(long long n, long long r) {
  long long res = 1;
  for (int i = 0; i < r; i++) {
    res *= (n - i);
  }
  for (int i = 1; i <= r; i++) {
    res /= i;
  }
  return res;
}
int vsum(vector<int> v) {
  int res = 0;
  for (auto it = v.begin(); it != v.end(); it++) res += *it;
  return res;
}
int vmin(vector<int> v) {
  int min = INT32_MAX;
  for (auto it = v.begin(); it != v.end(); it++) min = std::min(min, *it);
  return min;
}
int vmax(vector<int> v) {
  int max = 0;
  for (auto it = v.begin(); it != v.end(); it++) max = std::max(max, *it);
  return max;
}
long long gcd(long long A, long long B) {
  int r = A % B;
  while (r != 0) {
    A = B;
    B = r;
    r = A % B;
  }
  return B;
}
vector<bool> to_binary(int x) {
  vector<bool> res;
  while (x != 0) {
    res.push_back(x % 2);
    x /= 2;
  }
  return res;
}
