#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9;
const int MOD = 1000000007;
const double PI = acos(-1);
int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0};
void solve() {
  int n;
  cin >> n;
  vector<long long> v(n);
  for (int i = 0; i < (n); ++i) cin >> v[i];
  vector<long long> sum(n + 1);
  for (int i = 0; i < (n); ++i) sum[i + 1] = sum[i] + v[i];
  map<long long, int> mp;
  for (int i = 0; i < (n + 1); ++i) mp[sum[i]]++;
  long long ans = 0;
  for (auto p : mp) {
    ans += (p.second * (p.second - 1)) / 2;
  }
  cout << ans << endl;
}
int main() {
  solve();
  return 0;
}
