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

int main() {
	// your code goes here
	int n;
	cin>>n;
	
	vector<int> values(n);
	for(int i = 0; i < n; i++){
		cin>>values[i];
	}
	int k;
	cin>> k;
	
	int sum = 0, cnt = 0;
	unordered_map<int,int> ump;
	
	//edge case
	ump[0] = 1;
	
	for(int i = 0; i < n; i++){
		
		sum += values[i];
		
		// Find the remainder
		int rem = sum - k;
		
		// Find the frequency of it in the left
		if(ump.count(rem)){
			cnt += ump[rem];
		}
		
		ump[sum]++;
	}
	
	cout<<cnt<<endl;
	
	return 0;
}