import java.io.BufferedInputStream; import java.util.Arrays; import java.util.Scanner; public class Main { static final long C = 1000000007; static final int CY = 1000000000; StringBuilder sb; public void calc() { sb = new StringBuilder(); BufferedInputStream bs = new BufferedInputStream(System.in); Scanner sc = new Scanner(bs); int n = sc.nextInt(); int k = sc.nextInt(); int[][] a = new int[k][1+n/k]; for (int i=0; i < k; i++) { Arrays.fill(a[i], Integer.MAX_VALUE); } for (int i=0; i < n; i++) { a[i%k][i/k] = sc.nextInt(); //System.out.println(i%k+":"+i/k); } long ans = 0; for (int v = 0; v < k; v++) { for (int i=0; i < a[v].length; i++) { for (int t=0; t a[i%k][i/k]){ ans = -1; break; } } System.out.println(ans); } public static void main(String[] args) { Main main = new Main(); main.calc(); } }