#include <bits/stdc++.h>
using namespace std;
const int INF = (int)1e9;
const long long IINF = 1LL << 62;
const int maxn = 10000005;
long long modexpo(long long a, long long b) {
  long long res = 1LL;
  while (b > 0) {
    if (b & 1) res = (res * a) % 1000000007;
    a = (a * a) % 1000000007;
    b >>= 1;
  }
  return res;
}
int main() {
  long long n;
  cin >> n;
  long long a[n];
  for (int i = 0; i < n; i++) cin >> a[i];
  map<long long, int> mp;
  long long sum = 0;
  for (int i = 0; i < n; i++) {
    sum += a[i];
    mp[sum]++;
  }
  long long res = 0;
  for (auto it : mp) {
    if (it.first == 0) {
      res += it.second;
      res += (it.second) * (it.second - 1) / 2;
    } else {
      int ct = it.second;
      if (ct >= 2) {
        res += (ct) * (ct - 1) / 2;
      }
    }
  }
  cout << res;
}
