#include <bits/stdc++.h>
using namespace std;
const int MOD = 1000000007;
const int INF = 0x3f3f3f3f;
const long long INFL = 0x3f3f3f3f3f3f3f3f;
int main() {
  int n;
  cin >> n;
  long long a[n];
  for (int i = 0; i < (n); i++) cin >> a[i];
  vector<long long> s(n + 1);
  s[0] = 0;
  for (int i = 0; i < (n); i++) s[i + 1] = s[i] + a[i];
  sort(s.begin(), s.end());
  int sum = 1;
  int ans = 0;
  for (int i = 0; i < (n); i++) {
    if (s[i] == s[i + 1])
      sum++;
    else {
      ans += sum * (sum - 1) / 2;
      sum = 1;
    }
    if (i == n - 1) ans += sum * (sum - 1) / 2;
  }
  cout << ans << endl;
  return 0;
}
