// editor1
#include<stdio.h>
#include<stdlib.h>
typedef struct Treenode{
    int data;
}node;
int main(){
    int N,L;
    (scanf("%d",&N);
    scanf("%d",&L);
    Node arr[N];
    for(int i=0;i<N;i++){
        scanf("%d",&arr[i].data);
    }
}
int sum = 0;
int node = 1;
int level = 0;
int count = 0;
for(int i=0; i<N; i++){
    if(level==L){
        sum+=arr[i].data;
    }
    count++;
    if(count == node){
        level++;
        count == 0;
        node*=2;
    }
    printf("%d",&sum);
}