String Sort related problem

where is problem in my code i have given 3 String but on output console only two string are shown.

import java.util.Arrays;
import java.util.Scanner;

public class StringSort {
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
int n = sc.nextInt();
String[] str=new String[n];
for(int i=0;i<str.length;i++) {
str[i]=sc.nextLine();
}
for(int i = 0; i < n-1; ++i) {
for (int j = i+1; j < n; ++j) {
if (str[i].compareTo(str[j]) > 0) {
String temp = str[i];
str[i] = str[j];
str[j] = temp;
}
}
}
for(int i = 0; i <n; i++) {
System.out.println(str[i]);
}
}

}

here is my code