```
func dominantIndex(nums []int) int {
if len(nums) == 1{
return 0
}
min := math.MinInt32
max := nums[0]
midx := 0
for i,v := range nums[1:]{
if v > max{
min = max
max = v
midx = i + 1
}else if(v > min){
min = v
}
}
if max >= min*2 || min == 0 {
return midx
}
return -1
}
```