#include <bits/stdc++.h>
using namespace std;
const int MAXN = 100000;
int arr[MAXN];
int tree[4*MAXN];
// Hàm gcd có sẵn trong <algorithm> (C++17) là std::__gcd(x, y);
void build_tree(int index, int start, int end) {
if (start == end) {
tree[index] = arr[start];
return;
}
int mid = (start + end) / 2;
build_tree(index*2, start, mid);
build_tree(index*2+1, mid+1, end);
tree[index] = std::__gcd(tree[index*2], tree[index*2+1]);
}
int get_gcd(int index, int start, int end, int L, int R) {
if (end < L || start > R) return 0; // segment hoàn toàn ngoài [L, R]
if (L <= start && end <= R) return tree[index]; // segment nằm gọn trong [L, R]
int mid = (start + end) / 2;
int gcdLeft = get_gcd(index*2, start, mid, L, R);
int gcdRight = get_gcd(index*2+1, mid+1, end, L, R);
return std::__gcd(gcdLeft, gcdRight);
}
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int n, k;
cin >> n >> k;
for (int i = 0; i < n; i++) {
cin >> arr[i];
}
// Xây cây segment
build_tree(1, 0, n-1);
int ans = 1;
for (int start = 0; start <= n-k; start++) {
int g = get_gcd(1, 0, n-1, start, start + k - 1);
ans = max(ans, g);
}
cout << ans << "\n";
return 0;
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+CnVzaW5nIG5hbWVzcGFjZSBzdGQ7CiAKY29uc3QgaW50IE1BWE4gPSAxMDAwMDA7IAppbnQgYXJyW01BWE5dOwppbnQgdHJlZVs0Kk1BWE5dOwogCi8vIEjDoG0gZ2NkIGPDsyBz4bq1biB0cm9uZyA8YWxnb3JpdGhtPiAoQysrMTcpIGzDoCBzdGQ6Ol9fZ2NkKHgsIHkpOwogCnZvaWQgYnVpbGRfdHJlZShpbnQgaW5kZXgsIGludCBzdGFydCwgaW50IGVuZCkgewogICAgaWYgKHN0YXJ0ID09IGVuZCkgewogICAgICAgIHRyZWVbaW5kZXhdID0gYXJyW3N0YXJ0XTsKICAgICAgICByZXR1cm47CiAgICB9CiAgICBpbnQgbWlkID0gKHN0YXJ0ICsgZW5kKSA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