#include <bits/stdc++.h>
using namespace std;
long long N, M, H, W;
long long A[200001];
long long B[200001] = {};
long long x[51][2] = {};
long long y[2][200] = {};
int ayasi[5] = {};
bool r[52] = {};
int check[102][102] = {};
long long result = 0;
string S;
vector<long long> vl;
int main() {
  cin >> N;
  M = 0;
  for (int i = 0; i < N; i++) {
    cin >> A[i];
    if (i == 0) {
      B[i] = A[i];
    } else {
      B[i] = B[i - 1] + A[i];
    }
    if (B[i] == 0) {
      M++;
    }
    vl.push_back(B[i]);
  }
  sort(vl.begin(), vl.end());
  while (vl.size() >= 1) {
    for (int i = 0; i < vl.size(); i++) {
      if (vl[i] != vl[0]) {
        M += i * (i - 1) / 2;
        vl.erase(vl.begin(), vl.begin() + i);
        break;
      } else if (i == vl.size() - 1) {
        M += i * (i + 1) / 2;
        vl.clear();
        break;
      }
    }
  }
  cout << M << endl;
  return 0;
}
