#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  unordered_map<long long, int> table;
  table[0]++;
  long long a, sum = 0;
  for (int i = 0; i < (n); i++) {
    cin >> a;
    sum += a;
    table[sum]++;
  }
  int cou = 1, res = 0;
  for (pair<long long, int> p : table) {
    int ps = p.second;
    res += (ps - 1) * ps / 2;
  }
  cout << res << endl;
}
