#include<cmath> #define N 100001 usingnamespace std; intgcd(int a, int b){ return b == 0 ? a : gcd(b, a % b); } int arr[N]; int dp[21][N]; int n; inlineintread(){ int x = 0, f = 1; char ch = getchar(); while (ch < '0' || ch > '9') { if (ch == '-') f = -1; ch = getchar(); } while (ch >= '0' && ch <= '9') { x = x * 10 + ch - 48; ch = getchar(); } return x * f; } voidinit(){ int s = log2(n); for (int i = 1; i <= s; i++) { for (int j = 0; j <= n - (1 << i); j++) { dp[i][j] = gcd(dp[i - 1][j], dp[i - 1][j + (1 << (i - 1))]); } } } intquery(int l, int r){ int k = log2(r - l + 1); returngcd(dp[k][l], dp[k][r - (1 << k) + 1]); } intmain(){ int m; n = read(); m = read(); for (int i = 0; i < n; i++) { dp[0][i] = read(); } init(); int l, r; for (int i = 0; i < m; i++) { l = read(); r = read(); printf("%d\n", query(l - 1, r - 1)); } }