#include using namespace std; int subarraySum(vector& nums, int k) { unordered_map mp; mp[0] = 1; int count = 0, pre = 0; for (auto& x:nums) { pre += x; if (mp.find(pre - k) != mp.end()) { count += mp[pre - k]; } mp[pre]++; } return count; } int main() { int n; cin >> n; vector nums(n); for(int i = 0; i < n; i++){ cin >> nums[i]; } int k; cin >> k; cout << subarraySum(nums, k) << endl; return 0; }