#include <bits/stdc++.h>
using namespace std;
const int INF = 20050208;
int sum[200005];
int main() {
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> sum[i];
  }
  for (int i = 1; i <= n; i++) {
    sum[i] += sum[i - 1];
  }
  sort(sum + 1, sum + n + 1);
  int ans = 0;
  for (int i = 1; i <= n; i++) {
    if (sum[i] == sum[i - 1]) {
      int beg = i - 1;
      while (sum[i] == sum[i - 1]) {
        i++;
      }
      int end = i - 1;
      int a = end - beg + 1;
      ans += a * (a - 1) / 2;
    }
  }
  cout << ans << endl;
  return 0;
}
