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