from functools import cache @cache def f(p): ans = -sum(p) if not p: return 0 n = len(p) for i in range(n): x = p[i] if x <= k: ans = max(ans, x - f(tuple(sorted(p[:i] + p[i+1:])))) else: for s in range(1, x): ans = max(ans, -f(tuple(sorted(p[:i] + p[i+1:] + (s, x - s))))) return ans from random import * # k = int(input()) # k=3 def solve(k, inp): d1 = [] d2 = [] for x in inp: if x <= k: d1.append(x) else: d2.append(x) d1.sort(reverse=True) res = sum(d1[0::2]) - sum(d1[1::2]) turn = len(d1) % 2 if sum(d2) % 2: if (turn + len(d2)) % 2 == 0: res += 1 else: res -= 1 return res for _ in range(0): k = randrange(1, 6) inp = tuple(sorted(randrange(1, 10) for _ in range(randrange(1, 5)))) f.cache_clear() res = solve(k, inp) # print(k, inp, f(inp), res) assert f(inp) == res # print(f(inp)) n, k = map(int, input().split()) a = tuple(sorted(map(int, input().split()))) print((solve(k, a) + sum(a)) // 2)