N, K = map(int, input().split()) table = list(map(int, input().split())) restable = [] sumnum = 0 for i in range(0, K): if i < N: f = table[i] else: f = sum(restable[i-N:i]) restable.append(f) sumnum += f print(restable[len(restable) - 1], sumnum)