import java.util.ArrayList;
import java.util.Scanner;
public class Main {
public static void main(String [] args) {
ArrayList numbers = new ArrayList<>();
System.out.println("Enter numbers one after another. Once done enter -1");
Scanner scan = new Scanner(System.in);
int num = scan.nextInt();
while (num != -1) {
int index = 0;
for (int i = 0; i < numbers.size(); i++) {
if (numbers.get(i) < num) {
index++;
}
}
numbers.add(index, num);
num = scan.nextInt();
}
System.out.println("The final array is: " + numbers);
}
}