1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#include <iostream>
#include <algorithm>
using namespace std;
int bit(int a,int b=1){
	while(a>0){
	if(a%2==1)b++;
		
		a=a/2;
	}
	
	return b;
}

int main()
{
    int lic,mbi,dl,m=1;long long jak=0,k;
    cin>>lic>>mbi;
    
    for(int i=mbi-lic+1;i<=mbi;){
    	cin>>dl;
    	m=0;
    	m=bit(i,m);
    	k=dl*m;
    	jak=jak+k;
    
		
	i++;	
	}
	cout<<jak;
    return 0;
}