#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 10;
int n;
map<int, int> f;
long long a[maxn];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  cout.tie(NULL);
  cin >> n;
  long long answer = 0;
  f[0] = 1;
  for (int i = 1; i <= n; ++i) {
    cin >> a[i];
    a[i] += a[i - 1];
    answer += f[a[i]];
    f[a[i]]++;
  }
  cout << answer << "\n";
  return 0;
}
