#include <bits/stdc++.h>
using namespace std;
long long max(long long x, long long y) {
  if (x > y)
    return x;
  else
    return y;
}
long long min(long long x, long long y) { return x + y - max(x, y); }
const long long big = 1000000007;
int exp(int x, int y) {
  if (y == 0) return 1;
  if (x == 1 || x == 0) return x;
  if (y % 2 == 1) return (exp(x, y - 1) * x) % big;
  int t = exp(x, y / 2);
  return (t * t) % big;
}
void chmin(long long a, long long b) {
  if (a > b) a = b;
  return;
}
int main() {
  int n;
  cin >> n;
  vector<long long> a(n + 1);
  map<int, long long> ans;
  a[0] = 0;
  ans[0]++;
  for (int i = 0; i < (int)(n); i++) {
    int b;
    cin >> b;
    a[i + 1] = a[i] + b;
    ans[a[i + 1]]++;
  }
  long long cnt = 0;
  for (auto v : ans) {
    cnt += v.second * (v.second - 1) / 2;
  }
  cout << cnt << endl;
}
