1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
#include <iostream>
using namespace std;
int main()
{
	int n;
	long long m;
	cin >> n >> m;
	long long qual{};
	long long bi = m - n + 1;
	for (int i = 0; i < n; ++i, ++bi)
	{
		long long a;
		cin >> a;
		int C{};
		for (int j = 0; j < 64; ++j)
			if (bi >> j & 1) ++C;
		qual += a*C;
	}
	cout << qual << endl;
	return 0;
}