#include <bits/stdc++.h>
using namespace std;
map<long long, int> mp;
int main() {
  int n;
  cin >> n;
  long long sum = 0, ans = 0;
  for (int i = 1; i <= n; i++) {
    int x;
    cin >> x;
    sum += x;
    ans += mp[sum];
    mp[sum]++;
  }
  cout << ans;
  return 0;
}
