#include <bits/stdc++.h>
using namespace std;
int vx[] = {0, 0, -1, 1};
int vy[] = {1, -1, 0, 0};
int dx[] = {1, 0, -1, 1, -1, 1, 0, -1};
int dy[] = {1, 1, 1, 0, 0, -1, -1, -1};
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a * b / gcd(a, b); }
const long long mod = 1e9 + 7;
const int INF = INT_MAX / 2;
int n;
int a[200020];
long long cnt = 0;
int main() {
  cin >> n;
  for (int i = 0; i < int(n); i++) cin >> a[i];
  vector<long long> s(n + 1);
  s[0] = 0;
  for (int i = 1; i < n + 1; i++) {
    s[i] += s[i - 1] + a[i - 1];
  }
  sort(s.begin(), s.end());
  long long temp = 1;
  for (int i = 0; i < int(n + 1); i++) {
    if (s[i] == s[i + 1])
      temp++;
    else {
      cnt += temp * (temp - 1) / 2;
      temp = 1;
    }
  }
  cnt += temp * (temp - 1) / 2;
  cout << cnt << endl;
  return 0;
}
