import sys
def solve():
input_data = sys.stdin.read().split()
if not input_data:
return
data = [int(x) for x in input_data]
times = data[1:]
times.sort(reverse=True)
total_time = 0
i = 0
n = len(times)
while i < n:
if i + 1 < n:
total_time += times[i]
i += 2
else:
total_time += times[i]
i += 1
print(total_time)
if __name__ == "__main__":
solve()
aW1wb3J0IHN5cwoKZGVmIHNvbHZlKCk6CiAgICBpbnB1dF9kYXRhID0gc3lzLnN0ZGluLnJlYWQoKS5zcGxpdCgpCiAgICAKICAgIGlmIG5vdCBpbnB1dF9kYXRhOgogICAgICAgIHJldHVybgoKICAgIGRhdGEgPSBbaW50KHgpIGZvciB4IGluIGlucHV0X2RhdGFdCiAgICAKICAgIHRpbWVzID0gZGF0YVsxOl0KICAgIAogICAgdGltZXMuc29ydChyZXZlcnNlPVRydWUpCiAgICAKICAgIHRvdGFsX3RpbWUgPSAwCiAgICBpID0gMAogICAgbiA9IGxlbih0aW1lcykKCiAgICB3aGlsZSBpIDwgbjoKICAgICAgICBpZiBpICsgMSA8IG46CiAgICAgICAgICAgIHRvdGFsX3RpbWUgKz0gdGltZXNbaV0KICAgICAgICAgICAgaSArPSAyCiAgICAgICAgZWxzZToKICAgICAgICAgICAgdG90YWxfdGltZSArPSB0aW1lc1tpXQogICAgICAgICAgICBpICs9IDEKCiAgICBwcmludCh0b3RhbF90aW1lKQoKaWYgX19uYW1lX18gPT0gIl9fbWFpbl9fIjoKICAgIHNvbHZlKCk=