WA in DWW19B

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");
	}
}

The key was to find the minimum LCM of K with an element in A. Also, you had to look for overflows to solve the last sub task. Please refer to this post for that part.

Thanks bro,

Bro Please add problems to practice.

I have mailed the admin twice now, still no reply till now.
@admin @vijju123