#include <bits/stdc++.h>
using namespace std;
const int MAX = 1e5 + 5;
const int INF = 1001001001;
const int MOD = 1e9 + 7;
int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  for (int i = 0; i < (N); ++i) {
    cin >> A[i];
  }
  vector<int> sum(N + 1);
  sum[0] = 0;
  for (int i = 0; i < (N); ++i) {
    sum[i + 1] = sum[i] + A[i];
  }
  map<int, int> m;
  for (int i = 0; i < (N + 1); ++i) {
    m[sum[i]]++;
  }
  int ans = 0;
  for (auto i : m) {
    int c = i.second;
    ans += c * (c - 1) / 2;
  }
  cout << ans << endl;
}
