import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = 7;
int[] arr = new int[n];
for (int i=0; i<n; i++) {
arr[i] = sc.nextInt();
}
arr[0] = sc.nextInt();
int new_idx = 0;
while (true) {
int next_idx1 = new_idx*2+1;
int next_idx2 = new_idx*2+2;
int smallest = new_idx;
if(next_idx1 < n && arr[next_idx1] < arr[smallest]) {
smallest = next_idx1;
}
if(next_idx2 < n && arr[next_idx2] < arr[smallest]) {
smallest = next_idx2;
}
if (smallest == new_idx) {
break;
}
int temp = arr[new_idx];
arr[new_idx] = arr[smallest];
arr[smallest] = temp;
new_idx = smallest;
}
for (int i=0; i<n-1; i++) {
System.out.print(arr[i] + " ");
}
System.out.print(arr[n-1]);
}
}
To embed this project on your website, copy the following code and paste it into your website's HTML: