# 학생 수 N, 구간 수 K
N, K = map(int, input().split())
# 점수
point = list(map(int, input().split()))
for i in range(K):
# x~y 구간
x, y = map(int, input().split())
# 평균
n = sum(point[x-1:y]) / (y-(x-1))
# 소수점 2자리까지만 출력
print("{:.2f}".format(n))