#include <bits/stdc++.h>
using ll = long long;
using itn = int;
using namespace std;
using Graph = vector<vector<int>>;
static const long double GRATIO = (long double)(1 + sqrt(5)) / 2;
ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }
ll LCM(ll a, ll b) { return a / GCD(a, b) * b; }
int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  for (int i = 0; i < int(N); ++i) cin >> A[i];
  vector<int> sum(N + 1, 0);
  map<int, int> num;
  for (int i = 0; i < int(N); ++i) sum[i + 1] = sum[i] + A[i];
  sort(sum.begin(), sum.end());
  for (int i = 0; i < int(N + 1); ++i) num[sum[i]]++;
  ll ans = 0;
  for (auto i = num.begin(); i != num.end(); i++) {
    int s = i->second;
    ans += s * (s - 1) / 2;
  }
  cout << ans << endl;
}
