Can anyone tell what’s wrong in my approach?

```
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner s = new Scanner(System.in);
int t = Integer.parseInt(s.next());
while(t-->0) {
int n = s.nextInt();
long k = s.nextLong();
long[] visit = new long[n];
long wait = Integer.MAX_VALUE;
for(int i = 0 ; i < n ; i++){
visit[i] = s.nextLong();
if(Math.max(k, visit[i]) % Math.min(k, visit[i]) == 0) {
long temp = Math.max(k, visit[i]);
if(temp < wait)
wait = temp;
}
if(wait > visit[i] * k)
wait = visit[i] * k;
}
if(wait < Long.MAX_VALUE)
System.out.println(wait);
else
System.out.println("-1");
}
}
```