#include <bits/stdc++.h>
using namespace std;
long long arr[100005];
map<long long, int> freqArr;
int main() {
  int n;
  cin >> n;
  long long Sum = 0;
  for (int i = 1; i <= n; i++)
    scanf("%lld", &arr[i]), Sum += arr[i], freqArr[Sum]++;
  Sum = 0;
  int ans = 0;
  for (int i = 1; i <= n; i++) {
    ans += freqArr[Sum];
    Sum += arr[i];
    freqArr[Sum]--;
  }
  cout << ans;
  return 0;
}
