#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int MAX = 10000000;
const int MOD = 1000000007;
const int INF = 1e9;
int main() {
  int n, ans = 0;
  cin >> n;
  vector<int> s(n, 0), A(n, 0);
  for (int i = 0; i < n; i++) {
    cin >> A[i];
  }
  s[0] = A[0];
  for (int i = 1; i < n; i++) {
    s[i] = s[i - 1] + A[i];
  }
  map<int, int> ma;
  ma[0]++;
  for (int i = 0; i < n; i++) {
    ma[s[i]]++;
  }
  for (auto m : ma) {
    ans += m.second * (m.second - 1) / 2;
  }
  cout << ans << endl;
}
