"use strict";

const main = arg => {
    const N = arg.split("\n")[0].split(" ").map(n=>parseInt(n)).sort((a,b)=>a-b);
    const K = arg.split("\n")[1];
    const target = N.reduce((m,n)=>m>n?m:n) * 2 * K ;
    N.pop();
    N.push(target);
    
    console.log(N.reduce((m,n)=>m+n));
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));