Check this example:

```
Dim myArray As Integer() = {1, 2, 3, 5, 6, 8, 9, 7, 10, 20, 21, 23, 22}
Dim result As Integer()() = myArray _
.OrderBy(Function(x) x) _
.Select(Function(x, i) New With {x, i, .d = x - i}) _
.GroupBy(Function(t) t.d) _
.Select(Function(g) New Integer() {g.Min(Function(t) t.x), g.Max(Function(t) t.x)}) _
.ToArray
```

It returns a bidimensional array; each row contains the range.