#include <bits/stdc++.h>
using namespace std;
const long long INFL = 1e18;
const int INF = 1001001001;
const int mod = 1000000007;
const double PI = acos(-1);
int main() {
  int n;
  cin >> n;
  int a[n];
  for (int i = 0; i < (n); i++) cin >> a[i];
  long long sum[n + 1];
  sum[0] = 0;
  for (int i = 0; i < (n + 1); i++) {
    if (i == 0) continue;
    sum[i] = sum[i - 1] + a[i];
  }
  map<long long, int> m;
  for (int i = 0; i < (n + 1); i++) {
    m[sum[i]]++;
  }
  long long ans = 0;
  for (auto x : m) {
    ans += (x.second * (x.second - 1)) / 2;
  }
  cout << ans << endl;
}
