#include <iostream>
float handle_query(unsigned int numbers[], unsigned int a, unsigned int b) {
float avg = 0;
for (size_t i = a; i <= b; i++) {
avg += numbers[i];
}
avg /= (b-a + 1);
float err = 0;
for (size_t i = a; i <= b; i++) {
err += (numbers[i] - avg) * (numbers[i] - avg);
}
err /= (b-a + 1);
return err;
}
int main()
{
std::ios_base::sync_with_stdio(0);
std::cin.tie(0);
unsigned int n, q;
std::cin >> n >> q;
unsigned int numbers[100000];
unsigned int nb;
for (size_t i = 0; i < n; i++) {
std::cin >> nb;
numbers[i] = nb;
}
unsigned int a,b;
for (size_t i = 0; i < q; i++) {
std::cin >> a >> b;
std::cout <<std::fixed << handle_query(numbers, a-1, b-1) << std::endl;
}
return 0;
}