module app;

import core.bitop;

import std.algorithm;
import std.array;
import std.bigint;
import std.conv;
import std.container.rbtree;
import std.stdio;
import std.string;

void main()
{
    Input input = void;
    parseInput(input, stdin);
    auto result = main2(&input);
    writeln(result);
}

auto main2(Input* input)
{
    auto array = input.a.sort!("a>b").array;

	uint[32] powBuckets;

	foreach (i, a; array)
	{
		auto rank = bsr(a);
		powBuckets[rank] = i + 1;
	}

	auto waribikiken = input.m;
	int lastNum = -1;
	foreach_reverse (num; powBuckets)
	{
		uint waribikikenToUse = num;
		if (num != 0)
			waribikikenToUse = num;
		else if (lastNum != -1)
			waribikikenToUse = lastNum;

		if (waribikikenToUse <= waribikiken)
		{
			for (int i = 0; i < waribikikenToUse; i++)
				array[i] >>= 1;
			waribikiken -= waribikikenToUse;
			lastNum = waribikikenToUse;
		}
		else
			break;
	}

	while (waribikiken >= array.length)
	{
		foreach (ref a; array)
			a >>= 1;
		waribikiken -= array.length;
	}

	array.sort!("a>b");

	for (int j = 0; j < waribikiken; j++)
		array[j] >>= 1;

    BigInt count = 0;
	foreach (a; array)
		count += a;
    return count;
}

unittest { writefln("begin unittest"); }

unittest // example1
{
    string example =
`3 3
2 13 8`;
    Input input = void;
    parseExample(input, example);
    auto result = main2(&input);
    assert(result == 9);
}

unittest // example2
{
    string example =
`4 4
1 9 3 5`;
    Input input = void;
    parseExample(input, example);
    auto result = main2(&input);
    assert(result == 6);
}

unittest // example3
{
    string example =
`1 100000
1000000000`;
    Input input = void;
    parseExample(input, example);
    auto result = main2(&input);
    assert(result == 0);
}

unittest // example4
{
    string example =
`10 1
1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000`;
    Input input = void;
    parseExample(input, example);
    auto result = main2(&input);
    assert(result == 9500000000);
}

unittest { writefln("end unittest"); }

struct Input
{
	uint n,m;
    uint[] a;
}

void parseInput(T)(out Input input, T file)
{
    with (file) with (input)
    {
		auto nm = readln().strip().split().map!(a=>a.to!uint).array();
		n = nm[0]; m = nm[1];
        input.a = readln().strip().split().map!(a=>a.to!uint).array();
    }
}

void parseExample(out Input input, string example)
{
    struct Adapter
    {
        import std.string;

        string[] _lines;
        this(string input) { _lines = input.splitLines(); }

        string readln()
        {
            auto line = _lines[0];
            _lines = _lines[1..$];
            return line;
        }
    }
    Adapter a = Adapter(example);
    parseInput(input, a);
}
