#include <iostream>
#include <map>
using namespace std;

int main() {
  int n;
  cin >> n;
  map<long long, long long> list;
  list[0] = 1;
  long long ans = 0, sum = 0;
  for (int i = 0; i < n; i++) {
    int a;
    cin >> a;
    sum += a;
    ans += list[sum];
    list[sum]++;
  }
  cout << ans << endl;
  return 0;
}