#include <bits/stdc++.h>
using namespace std;
const double PI = acos(-1.0);
const double EPS = 1e-11;
const long long MOD = 1000000007;
const int N = 100000;
void fast() { std::ios_base::sync_with_stdio(0); }
int main() {
  int n, x, cnt = 0;
  scanf("%d", &n);
  int sum = 0;
  unordered_map<int, int> ump;
  for (int i = 0; i < n; i++) {
    scanf("%d", &x);
    sum += x;
    if (sum == 0) cnt++;
    if (ump.find(sum) != ump.end()) cnt += ump[sum];
    ump[sum]++;
  }
  printf("%d\n", cnt);
  return 0;
}
