human
Solve in Python:
Binod and his family live in Codingland. They have a festival called N-Halloween.
The festival is celebrated for N  consecutive days. On each day Binod gets some candies from his mother. He may or may not take them. On a given day ,  Binod will be sad if he collected candies on that day and he does not have at least X   candies remaining  from the candies he collected that day at the end of that day . His friend Pelu who is very fond of candies asks for X  candies from Binod on a day if Binod collects any candy on that day. He does so immediately after Binod collects them. Binod being a good friend never denies him.  

Given a list a   where ai   denotes the number of candies Binod may take on the ith   day and  Q  queries having a number X , find the maximum number of candies Binod can collect so that he won't be sad after the festival ends.
Input format: 

First-line contains two integers N and Q denoting the number of festival days and number of queries respectively.

The second line is the array whose ith   element is the maximum number of candies Binod may
collect on that day.

Each of the next Q lines contains the number X i.e the minimum number of candies Binod wants to have at the end of every day on which he collects any candy.
Output format: 

For every query output, a single integer denoting the max number of candies Binod may
collect (for the given X ) to be happy after the festival ends.
Constraints:  

1<=N,Q<=105  

1<=Q<=105  

0<=ai<=109  

0<=X<=109  

Sample Input : 

5 2

4 6 5 8 7

1

2

Sample Output : 

30

30

Sample Input:  

6 3 

20 10 12 3 30 5 

2 

6 

13 

Sample Output  

77 

62 

30 

Explanation: 

In the first query of sample input 1, Binod can collect the maximum number of given chocolates for a given day each day as after the end of every day Binod will have a number of collected
chocolates on that day greater than equal to 1 even after giving 1 chocolate to Pelu. So the
the answer is 4+6+5+8+7=30.
 ... Can you provide a Python code to find the maximum number of candies Binod can collect so that he won't be sad after the festival ends?
assistant
#Here is Python code to find the maximum number of candies Binod can collect so that he won't be sad after the festival ends.

from sys import stdin, stdout
import math,sys,heapq
from itertools import permutations, combinations
from collections import defaultdict,deque,OrderedDict
from os import path
import random
import bisect as bi
def yes():print('YES')
def no():print('NO')
if (path.exists('input.txt')): 
 #------------------Sublime--------------------------------------#
 sys.stdin=open('input.txt','r');sys.stdout=open('output.txt','w');
 def I():return (int(input()))
 def In():return(map(int,input().split()))
else:
 #------------------PYPY FAst I/o--------------------------------#
 def I():return (int(stdin.readline()))
 def In():return(map(int,stdin.readline().split()))
#sys.setrecursionlimit(1500)
def dict(a):
 d={} 
 for x in a:
  if d.get(x,-1)!=-1:
   d[x]+=1
  else:
   d[x]=1
 return d
def find_gt(a, x):
 'Find leftmost value greater than x'
 i = bi.bisect_right(a, x)
 if i != len(a):
  return i
 else:            
  return -1

def find_ge(a, x):
 'Find leftmost item greater than or equal to x'
 i = bi.bisect_left(a, x)
 if i != len(a):
  return i
 else:
  return -1
def main():
 try:
  n,Q=In()
  l=list(In())
  l.sort()
  pre=[0]
  su=0
  for x in range(n):
   su+=l[x]
   pre.append(su)
  #print(pre)
  for x in range(Q):
   q=I()
   q*=2
   pos=find_ge(l,q)
   #print(pos)
   if pos==-1:
    print(0)
   else:
    #print(pos)
    ans=pre[-1]-pre[pos]
    print(ans)
 except:
  pass
  
M = 998244353
P = 1000000007
 
def __starting_point():
 #for _ in range(I()):main()
 for _ in range(1):main()
__starting_point()