#include <bits/stdc++.h>
using namespace std;
const long long int MOD = 1234567;
const long long int INF = 1000000010;
const long long int LINF = 1000000000000000010LL;
const int MAX = 500010;
const double EPS = 1e-3;
int dx[4] = {0, 1, 0, 1};
int dy[4] = {0, 0, 1, 1};
int main() {
  int n;
  cin >> n;
  int a[200010];
  int sum[200010];
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    sum[i + 1] = sum[i] + a[i];
  }
  sort(sum, sum + n + 1);
  long long int ans = 0;
  long long int c = 1;
  for (int i = 1; i <= n; i++) {
    if (sum[i] == sum[i - 1]) {
      c++;
    } else {
      ans += c * (c - 1) / 2;
      c = 1;
    }
  }
  ans += c * (c - 1) / 2;
  cout << ans << endl;
  return 0;
}
