Chef and Digits

All submissions for this problem are available.
Read problems statements in Mandarin Chinese and Russian.
Yesterday Chef had a great party and doesn't remember the way he celebreated it. But he found a strange paper in his kitchen containing n digits (lets give them indices from 1 to n and name them a_{1}, a_{2} ... a_{N}).
Chef remembers that he played such game:
 On each step he choose an index x from 1 to n.
 For all indices y (y < x) he calculated the difference b_{y} = a_{x}  a_{y}.
 Then he calculated B1  sum of all b_{y} which are greater than 0 and B2  sum of all b_{y} which are less than 0.
 The answer for this step is B1  B2.
Input
 The first line contains two integers n, m denoting the number of digits and number of steps. The second line contains n digits (without spaces) a_{1}, a_{2}, ..., a_{n}.
 Each of next m lines contains single integer x denoting the index for current step.
Output
 For each of m steps print single number in a line  answer of the step.
Constraints
 1 ≤ n, m ≤ 10^5
 0 ≤ a_{i} ≤ 9
 1 ≤ x ≤ n
Example
Input: 10 3 0324152397 1 4 7 Output: 0 7 9
Explanation
For index 1 there are no indexes which are less, so B1 = B2 = 0 and the answer is 0.
For index 4 we have b_{1} = 40=4, b_{2} = 43=1, b_{3} = 42=2, so B1 = 4+1+2 = 7, B2 = 0 and the answer is 7.
For index 7 we have b_{1} = 20=2, b_{2} = 23=1, b_{3} = 22=0, b_{4} = 24=2, b_{5} = 21=1, b_{6} = 25=3, so B1 = 2 + 1 = 3, B2 = 1 2 3 = 6 and the answer is 9.
Author:  berezin 
Tester:  shiplu 
Editorial  http://discuss.codechef.com/problems/ADIGIT 
Tags  adhoc, april14, berezin, easy 
Date Added:  20022014 
Time Limit:  1 sec 
Source Limit:  50000 Bytes 
Languages:  C, CPP14, JAVA, PYTH, PYTH 3.6, CS2, PAS fpc, PAS gpc, RUBY, PHP, GO, NODEJS, HASK, SCALA, D, PERL, FORT, WSPC, ADA, CAML, ICK, BF, ASM, CLPS, PRLG, ICON, SCM qobi, PIKE, ST, NICE, LUA, BASH, NEM, LISP sbcl, LISP clisp, SCM guile, JS, ERL, TCL, PERL6, TEXT, PYP3, CLOJ, FS 
Comments
 Please login at the top to post a comment.
SUCCESSFUL SUBMISSIONS
Fetching successful submissions
HELP
If you are still having problems, see a sample solution here. 