I am trying to write a bubble sort in vb and i have the algorithm right but it always says 'Index was outside the bounds of the array.' which i do not know how to fix. I will put the code below and any help will be good.

```
    Sub Main()
    Dim unsorted() As Integer = {17, 19, 12, 10, 15, 20}
    Dim n As Integer = unsorted.Length
    Dim swapped As Boolean = True
    Dim temp
    Dim list As String = ""

    While n > 0 And swapped = True
        For a = 0 To n - 1
            If unsorted(a) > unsorted(a + 1) Then
                temp = unsorted(a)
                unsorted(a) = unsorted(a + 1)
                unsorted(a + 1) = temp
                swapped = True
            End If
        Next
    End While
    For Each number In unsorted
        number &= list & " "
    Next
    Console.WriteLine(list)
    Console.ReadLine()
End Sub

```