#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
const long long MOD = 1000000007;
const long long Mod = 998244353;
const int MAX = 510000;
const double PI = 3.14159265358979;
const vector<int> dx = {1, 0};
const vector<int> dy = {0, 1};
int main() {
  int N;
  cin >> N;
  vector<long long> A(N);
  for (int i = 0; i < N; i++) cin >> A[i];
  vector<long long> sum(N);
  sum[0] = A[0];
  for (int i = 1; i < N; i++) sum[i] = sum[i - 1] + A[i];
  map<long long, int> dict;
  for (int i = 0; i < N; i++) {
    if (dict.count(sum[i]))
      dict[sum[i]]++;
    else
      dict[sum[i]] = 1;
  }
  long long res = 0;
  for (auto p : dict) {
    auto key = p.first;
    auto value = p.second;
    res += value * (value - 1) / 2;
    if (key == 0) res += value;
  }
  cout << res << endl;
  return 0;
}
