read N M
sort -n | awk -v M=$M '
{
    if ($2 < M) {
        sum+=$1*$2
        M-=$2
    } else {
        sum+=$1*M
        M=0
    }
    
    if (M == 0) {
        printf "%f", sum
        exit
    }
}' | sed 's/\..*//'