import Data.List

main = do
    str <- readFile "Problem0022.txt"
    print $ problem22Value str

problem22Value :: String -> Int
problem22Value str = sum $ getNameScores $ sort $ lines str

getNameScores :: [String] -> [Int]
getNameScores names = getNameScores' 1 names