#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  while (cin >> n) {
    map<long long int, int> m;
    vector<int> vec;
    pair<long long int, int> p(0, 0);
    m.insert(p);
    vec.push_back(1);
    int flag = 1, rst = 0;
    long long int in, sum = 0;
    for (int i = 0; i < n; ++i) {
      cin >> in;
      sum += in;
      if (m.find(sum) == m.end()) {
        pair<long long int, int> p0(sum, flag);
        m.insert(p0);
        vec.push_back(0);
        ++flag;
      }
      rst += vec[m[sum]];
      ++vec[m[sum]];
    }
    cout << rst << endl;
  }
  return 0;
}
