#include <bits/stdc++.h>
using namespace std;
long long MOD = 1000000000 + 7;
long long MAX = 1000000000000000000;
int main() {
  cout << setprecision(10);
  int N;
  cin >> N;
  map<long long, int> m;
  m[0] = 1;
  long long sum = 0;
  for (int i = 0; i < N; i++) {
    long long tmp;
    cin >> tmp;
    sum += tmp;
    m[sum]++;
  }
  long long ans = 0;
  for (auto x : m) {
    ans += x.second * (x.second - 1) / 2;
  }
  cout << ans << endl;
}
