#include <bits/stdc++.h>
using namespace std;
int asc(const void *a, const void *b) { return *(int *)a - *(int *)b; }
int desc(const void *a, const void *b) { return *(int *)b - *(int *)a; }
int main() {
  long long n, cnt = 1, ans = 0;
  cin >> n;
  vector<long long> dp(n + 1);
  dp[0] = 0;
  for (int(i) = (1); (i) < (n + 1); ++(i)) {
    cin >> dp[i];
    dp[i] += dp[i - 1];
  }
  sort(dp.begin(), dp.end() + 1);
  for (int(i) = 0; (i) < (n); ++(i)) {
    if (dp[i] == dp[i + 1]) {
      cnt++;
    } else {
      ans += cnt * (cnt - 1) / 2;
      cnt = 1;
    }
  }
  ans += cnt * (cnt - 1) / 2;
  cout << ans << endl;
  return 0;
}
