Sam and numbers

0

0 votes
Easy
Problem

Sam is amused by numbers so his friend gives him a puzzle to work upon. 
The puzzle is simple, given an array of N numbers, you have to find the number of unordered pairs with a sum of K. (These pairs need not be distinct)
Help Sam solve this puzzle for his friend.


INPUT:
The first line of input contains an integer N (the size of array) followed by N space seperated integers A[i]. 

The next line contains an integer K


OUTPUT:
Print the number of pairs with sum K


CONSTRAINTS:
1≤N≤106

1≤A[i]≤105

1≤K≤105

Time Limit: 1
Memory Limit: 256
Source Limit:
Explanation

The sum of 3 and 5 is 8. So, there is 1 pair with sum 8. Hence the output is 1

Editor Image

?