Debug the following Python program to print the given output.
a = [3,4,6,2,1]
for x in a:
 print(x)
Expected Output:
1
2
3
4
6
a = [3,4,6,2,1]
for x in a:
 print(x)
a.sort() 
for x in a:
 print(x) 

Output:
1
2
3
4
6