#P1423. F. AKIE's Penalty

F. AKIE's Penalty

题目描述

​ Have you ever heard of the ACM penalty time rules? Yes, that's exactly the rule for the competition you're in right now. Your total penalty time is the sum of the penalty time of your wrong submissions for each question plus the time when you pass each question. The penalty time for each wrong submission is 2020 .

​ Formally, there are NN questions in a contest that AKIE participate. Let KiKi be equal to the number of her submissions for the ii-thth problem and TiTi be equal to the time when AKIE passed the problem. Besides,

  1. Tigeq0Ti\\geq 0 means she passed the ii-thth question at the last submission of the KiKi submissions (and the former Ki1Ki-1 submissions are wrong).

  2. Ti=1Ti=-1 means she didn't pass the ii-thth question.

​ Now, give you a list of the number of AKIE's submissions KiKi and her passing time TiTi for each question. Please help AKIE calculate her total penalty time.

输入格式

The first line input a number NN,

The second line input N numbers of K1,K2,...,KnK1,K2,...,Kn, representing the number of submissions for each question.

The third line input N numbers of T1,T2,...,TnT1,T2,...,Tn, if Tigeq0Ti\\geq0, it means the passing time for the ii-thth question, else, if Ti=1Ti=-1, it means AKIE didn't pass tht ii-thth question.

1leqNleq1001\\leq N \\leq 100

0leqKileq1000\\leq Ki \\leq 100

1leqTileq300-1\\leq Ti \\leq 300

N,Ki,TiN, Ki, Ti are all integers.

It's guaranteed that if AKIE passed a question, there's at least one submission of this question.

Note that, AKIE's passing time TiTi for a question may be 00, because her coding ability is outstanding.

输出格式

Only a number representing AKIE's total penalty time.

样例

5 
1 2 3 4 5 
-1 0 20 30 40
290