#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  map<int, int> sum;
  sum[0] = 1;
  int sum1 = 0;
  for (int i = 0; i < n; i++) {
    int a;
    cin >> a;
    sum1 += a;
    sum[sum1] += 1;
  }
  int ans = 0;
  for (auto itr = sum.begin(); itr != sum.end(); ++itr) {
    int a = (itr->second) - 1;
    ans += a * (a + 1) / 2;
  }
  cout << ans;
}
