#include <bits/stdc++.h>
using namespace std;
const int INF = 100100100;
const long long LINF = 1e18 + 100;
const int MOD = 1e9 + 7;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  ;
  int N;
  cin >> N;
  unordered_map<long long, int> s;
  s[0]++;
  long long sum = 0;
  for (int i = 0; i < (N); i++) {
    long long a;
    cin >> a;
    sum += a;
    s[sum]++;
  }
  long long ans = 0;
  for (auto kv : s) {
    ans += (kv.second * kv.second - 1) / 2;
  }
  cout << ans << endl;
}
