from collections import defaultdict,Counter,deque from heapq import heappush,heappop,heapify from bisect import bisect,bisect_left from itertools import product,permutations,combinations,combinations_with_replacement from math import gcd import sys from functools import lru_cache if len(sys.argv)==2:sys.stdin=open(sys.argv[1]) input=sys.stdin.readline sys.setrecursionlimit(10**9) N,K=map(int,input().split()) A=list(map(int,input().split())) A.sort() M=1<0: if i&1: X%=A[-j] i>>=1 j+=1 X%=A[0] if ans