#1.军训排队
# 判断x能否加人group组
def check(x, group):
# 要保证不能存在倍数关系
for y in group:
if x % y == 0 or y % x == 0:
return False
return True
# depth表示当前为第depth个学生
def dfs(depth):
global ans
# 最优性剪枝:当前已经比ans大,说明该策略不可行
if len(Groups) > ans:
return
if depth == n:
ans = min(len(Groups), ans)
return
for each_group in Groups:
# 枚举第depth个学生能否加人当前组each_group
# 剪枝:必须满足题意
if check(a[depth], each_group):
each_group.append(a[depth])
dfs(depth + 1)
each_group.pop()
# 单独作为一组
Groups.append([a[depth]])
dfs(depth + 1)
Groups.pop()
n = int(input())
a = list(map(int, input().split()))
# ans表示最少能分多少队
ans = n
# Groups表示分组情况
Groups = []
dfs(0)
print(ans)
#2.特殊多边形
def dfs(depth, last_val, tot, mul):
'''
:param depth:第depth条边长
:param last_val:上一边长长度
:param tot:累计和
:param mul:累计乘积
'''
if depth == n:
# 前n-1条边之和大于第n条边
if tot - path[-1] > path[-1]:
ans[mul] += 1
return
for i in range(last_val + 1, 100001):
# 最优性剪枝,后续还有n-depth个数字,每个数字都要>=i
# 累计乘积要不超过100000:mul*(i*(n-depth))
if mul * (i ** (n - depth)) > 100000:
break
path.append(i)
dfs(depth + 1, i, tot + i, mul * i)
path.pop()
t, n = map(int,input().split())
ans = [0] * 100001
path = []
dfs(0, 0, 0, 1)
for i in range(1, 100001):
ans[i] += ans[i - 1]
for _ in range(t):
l, r = map(int,input().split())
print(ans[r] - ans[l - 1])