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