Go golang clean solution
go\n\nfunc semiOrderedPermutation(nums []int) int {\n    var i, j int\n    n := len(nums)\n    for idx, num := range nums {\n        if num == 1 {\n            
```go\n\nfunc semiOrderedPermutation(nums []int) int {\n    var i, j int\n    n := len(nums)\n    for idx, num := range nums {\n        if num == 1 {\n            i = idx\n        } else if num == n {\n            j = idx\n        }\n    }\n    if i < j {\n        return i + (n - j - 1)\n    }\n    return i + (n - j - 1) - 1\n}\n```
['Go']