# Topic : Greedy _ 2+1 세일 # # Python 3 : 시간초과 # PyPy 3 : 208ms N = int(input()) greek = [ int(input()) for _ in range(N) ] greek.sort(reverse=True) for i in range(2,N,3): greek[i] = 0 print(sum(greek))