n, m = map(int, input().split())
a = list(map(int, input().split()))
a.sort(reverse=True)
print(sum(a[:n // 2 * 2][::2]))