#include <bits/stdc++.h>
using namespace std;

int ans(vector<int>&pre,int k){
	int a=0;unordered_map<int,int>m;m[0]=1;
	for(int i=0;i<pre.size();i++){
		if(pre[i]==k)a++;
		if(m.find(pre[i]-k)!=m.end())a+=m[pre[i]-k];
		m[pre[i]]++;
	}
	return a;
}
int main() {
	// your code goes here
	int n;cin>>n;vector<int>pre(n);
	for(int i=0;i<n;i++){
		int e;cin>>e;
		if(i==0){
			pre[i]=e;
		}else{
			pre[i]=pre[i-1]+e;
		}
	}
	int k;cin>>k;
	cout<<ans(pre,k)<<endl;
	return 0;
}