/*
这个题需要同时访问最大和最小值,并把最小值加上一个输入的数。然后重复找最大最小值。
我最开始用的PriorityQueue,但是发现访问最小值之后没法直接访问最大值。
之后想用双端优先的TreeSet,跑案例的时候发现过去不全部的,
查了查才知道,TreeSet的直接把相同的元素合并了。
然后我又用回来了,加了一个max变量做最大值记录。
*/
import java.util.*;
import java.io.*;
public class Main {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
PrintWriter pw = new PrintWriter(System.out);
StreamTokenizer st = new StreamTokenizer(br);
PriorityQueue<Integer> pq = new PriorityQueue<>();
st.nextToken();
int N = (int)st.nval;
st.nextToken();
int M = (int)st.nval;
int max = Integer.MIN_VALUE;
while (N-- > 0) {
st.nextToken();
int temp = (int)st.nval;
pq.add(temp);
if (temp > max) {
max = temp;
}
}
while (M-- > 0) {
int temp = pq.poll();
st.nextToken();
int temp_new = temp + (int)st.nval;
pq.add(temp_new);
if (temp_new > max) {
max = temp_new;
}
pw.println(max);
}
pw.flush();
}
}