#!/usr/bin/env python


names = [n.strip('"') for n in open('names.txt', 'r').readline().split(',')]

# I trust that timsort is sufficient
names.sort()

totalSum = 0
startIndex = ord('A') - 1
for (position, name) in enumerate(names, 1):
    nameSum = 0
    for c in name:
        nameSum += ord(c) - startIndex

    totalSum += nameSum * position

print(totalSum)

581da01a69c69be88eac4bf33a8c4b23a566c188
<mask token>

<mask token>
names.sort()
<mask token>
for position, name in enumerate(names, 1):
    nameSum = 0
    for c in name:
        nameSum += ord(c) - startIndex
    totalSum += nameSum * position
print(totalSum)

names = [n.strip('"') for n in open('names.txt', 'r').readline().split(',')]
names.sort()
totalSum = 0
startIndex = ord('A') - 1
for position, name in enumerate(names, 1):
    nameSum = 0
    for c in name:
        nameSum += ord(c) - startIndex
    totalSum += nameSum * position
print(totalSum)

#!/usr/bin/env python


names = [n.strip('"') for n in open('names.txt', 'r').readline().split(',')]

# I trust that timsort is sufficient
names.sort()

totalSum = 0
startIndex = ord('A') - 1
for (position, name) in enumerate(names, 1):
    nameSum = 0
    for c in name:
        nameSum += ord(c) - startIndex

    totalSum += nameSum * position

print(totalSum)
