#include <bits/stdc++.h>
using namespace std;
int n, d;
long long x, t;
long long a[200000];
long long b[200001];
vector<long long> c1[100000];
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) scanf("%lld", a + i);
  for (int i = 0; i < n; i++) b[i + 1] = b[i] + a[i];
  for (int i = 0; i <= n; i++) {
    b[i] += 200000 * 1000 * 1000 * 1000;
    c1[b[i] % 100000].push_back(b[i] / 100000);
  }
  for (int i = 0; i < 100000; i++) {
    d = c1[i].size();
    sort(c1[i].begin(), c1[i].end());
    t = 1;
    for (int j = 0; j < d; j++) {
      if (c1[i][j] != c1[i][j + 1]) {
        x += t * (t - 1) / 2;
        t = 1;
      } else
        t++;
    }
    x += t * (t - 1) / 2;
  }
  printf("%lld\n", x);
}
