#include <bits/stdc++.h>
using namespace std;
const long long int MaxN = 10000005;
const long long int mod = 1e9 + 7;
const float pi = 3.1415926535897932384626433832795028;
long long int mcd(long long int a, long long int b) {
  if (a == 0) return b;
  return mcd(b % a, a);
}
map<int, int> cub;
int main() {
  cin.tie(0), ios_base::sync_with_stdio(0);
  long long int N, i, p, q, sum = 0, res = 0;
  cin >> N;
  cub[0] = 1;
  for (i = 0; i < N; i++) {
    cin >> p;
    sum += p;
    res += cub[sum];
    cub[sum] += 1;
  }
  cout << res;
}
