|Codeforces Round #365 (Div. 2)|
Little Mishka is a great traveller and she visited many countries. After thinking about where to travel this time, she chose XXX — beautiful, but little-known northern country.
Here are some interesting facts about XXX:
Mishka started to gather her things for a trip, but didn't still decide which route to follow and thus she asked you to help her determine summary price of passing each of the roads in XXX. Formally, for every pair of cities a and b ( a < b), such that there is a road between a and b you are to find sum of products c a·c b. Will you help her?
The first line of the input contains two integers n and k (3 ≤ n ≤ 100 000, 1 ≤ k ≤ n) — the number of cities in XXX and the number of capital cities among them.
The second line of the input contains n integers c 1, c 2, ..., c n (1 ≤ c i ≤ 10 000) — beauty values of the cities.
The third line of the input contains k distinct integers id 1, id 2, ..., id k (1 ≤ id i ≤ n) — indices of capital cities. Indices are given in ascending order.
Print the only integer — summary price of passing each of the roads in XXX.
2 3 1 2
3 5 2 2 4
This image describes first sample case:
It is easy to see that summary price is equal to 17.
This image describes second sample case:
It is easy to see that summary price is equal to 71.