27. Odd-Even Traffic Fine

Difficulty: easy · Array, Math

Problem

To reduce pollution, Delhi applies an odd-even rule: on odd dates only vehicles whose registration number ends in an odd digit may be on the road, and on even dates only those ending in an even digit. You are given the last digits `a[0..N-1]` of the registration numbers of `N` vehicles seen on date `D`. Every vehicle that breaks the rule is fined `X` rupees. Print the total fine collected (print `0` if no one is fined).

Input

- Line 1: the integer `N`. - Line 2: `N` space-separated digits `a[0] ... a[N-1]`. - Line 3: the integer `D`. - Line 4: the integer `X`.

Output

Print the total fine.

Example 1

Input:
4
5 2 3 7
12
200
Output:
600

Explanation: Date 12 is even, so the odd-numbered vehicles 5, 3 and 7 are fined 200 each: 600.

Example 2

Input:
5
2 5 1 6 8
3
300
Output:
900

Explanation: Date 3 is odd, so the even-numbered vehicles 2, 6 and 8 are fined 300 each: 900.

Constraints

- 1 <= N <= 10^5 - 0 <= a[i] <= 9 - 1 <= D <= 31 - 100 <= X <= 5000

Solutions are judged against 2 sample and 9 hidden tests. Sign in to solve it · All problems