402198: GYM100694 H Noisy Lecture

Memory Limit:256 MB Time Limit:2 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

H. Noisy Lecturetime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard output

Teacher N/A is delivering a lecture. The lecture consists of n sentences and goes this way: each sentence should be firstly remembered by the teacher from her copy-book (remembering the i-th sentence takes ai time) and then written on the blackboard (it takes bi time). If there is a noise in the lecture hall, N/A gets distracted: if she is remembering the sentence at this moment, she forgots it and will have to remember it from the beginning after the noise ends. And if she is writing the sentence on the blackboard, she will have to remember the remaining part of the sentence (she has to spend the corresponding part of ai for that) and write that part on the blackboard.

There are k students in the lecture hall. Each of these students can initiate the noise of duration cj exactly once. What is the maximal amount of time students can slow down the lecture?

Input

The first line contains a single integer n (1 ≤ n ≤ 1000) — the number of sentences in the lecture.

The second line contains n space-separated integers ai (1 ≤ ai ≤ 1000) — how much time it takes to remember the i-th sentence.

The third line contains n space-separated integers bi (1 ≤ bi ≤ 1000) — how much time it takes to write the i-th sentence on the blackboard.

The fourth line contains a single integer k (1 ≤ k ≤ 1000) — the number of students in the lecture hall.

The fifth line contains k space-separated integers cj (1 ≤ cj ≤ 1000) — the duration of noise which can be initiated by the j-th student.

Output

Output one integer — the maximal amount of time for which the lecture can be slowed down.

ExamplesInput
3
3 2 1
1 5 3
2
1 2
Output
9
Input
4
2 1 2 1
1 2 3 4
3
2 3 1
Output
12

加入题单

算法标签: