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