#include <bits/stdc++.h>
using namespace std;
const long double PI = (acos(-1));
const int INF = 1001001001;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, -1, 0, 1};
long long mod = 1000000007;
int main() {
  int n;
  cin >> n;
  vector<long long> a(n);
  for (int i = 0; i < (int)(n); i++) cin >> a[i];
  vector<long long> s(n + 1, 0);
  map<long long, long long> nums;
  for (int i = 0; i < (int)(n + 1); i++) s[i + 1] = s[i] + a[i];
  for (int i = 0; i < (int)(n + 1); i++) nums[s[i]]++;
  long long ans = 0;
  for (auto it : nums) {
    long long num = it.second;
    ans += num * (num - 1) / 2;
  }
  cout << ans;
  return 0;
}
