// Online C++ compiler to run C++ program online
#include <iostream>
#include <vector>
#include <cmath>
using namespace std;
int main() {
int n, q;
cin >> n >> q;
vector<int> arr(n);
vector<int> arr2(n);
int f = 0;
cin >> f;
arr[0] = f;
arr2[0] = f * f;
for (int i = 1; i < n; i++)
{
int t = 0;
cin >> t;
arr[i] = t + arr[i-1];
arr2[i] = t * t + arr2[i-1];
}
//for (int i = 0; i < n; i++)
// cout << arr[i] << " ";
for (int i = 0; i < q; i++)
{
int a, b;
cin >> a >> b;
double n = b-a+1;
a--;a--;
b--;
int sub = a >= 0 ? arr[a] : 0;
int c = arr[b] - sub;
int sub2 = a >= 0 ? arr2[a] : 0;
int c2 = arr2[b] - sub2;
//cout << c << " " << c2 << " " << n << endl;;
//double equation = ( 1.0/n*c + sqrt(pow(1.0/n*c, 2) - 4.0 * (1.0/n) * c2) ) / 2.0;
// cout << c2 * n << endl;
//double equation = ( c - sqrt(pow(c, 2) - c2 * n) ) / n;
double num = ((double)c) / n;
//cout << num << endl;
//cout <<
cout << c2 / n - 2 * c * num / n + num * num << endl;
// cout << equation << endl;
}
return 0;
}