Do you like golf? I hate it. I hate golf so much that I decided to build the ultimate golf robot, a robot that never misses a shot. I place it over the ball, choose the direction and the distance, and it strikes the ball across the air and into the hole. Golf will never be played again.
It did not work out that way. Standing on the green and preparing my first stroke, I noticed that the distance dial built into the robot does not carry every distance. Not everything is lost, because I get two strokes.
With the robot as it is, how many holes can I complete in two strokes or fewer?
The first line has one integer N, the number of different distances the Golf Bot can shoot. Each of the following N lines has one integer ki, the distance marked at position i of the dial.
The next line has one integer M, the number of holes in this course. Each of the following M lines has one integer dj, the distance from the Golf Bot to hole j.
Print one integer, the number of holes the Golf Bot can complete.
The Golf Bot cannot shoot past a hole on purpose and then shoot backwards. Hole j therefore falls only when one dial distance equals dj, or when two dial distances add up to dj. The same distance may be chosen for both strokes.
Suppose the Golf Bot can shoot the three distances 1, 3 and 5, and the course has holes at distances 2, 4, 5, 7, 8 and 9. Four of them fall.
The holes at distances 7 and 9 can never be reached.