// editor1
#include<stdio.h>
#include<stdlib.h>
typedef struct Treenode{
    int data;
}node;
int main(){
    int N,L;
    if(scanf("%d",&N)!=1 || N<0){;
    printf("Invalid input");
    return 0;
    }
    if(scanf("%d",&L)!=1 || L<0);{
        printf("Invalid input");
        return 0;
    }
    node arr[N];
 for(int i =0;i<N;i++){
     if(!scanf("%d",&arr[i].data)){
         printf("Invalid input");
         return 0;
     }
 }   

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);
}