#include <bits/stdc++.h>
#define F first
#define S second
#define X real()
#define Y imag()
using namespace std;
typedef long long ll;
typedef long double ld;
ld x[1010101];
ld xx[1010101];
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0);
int n,q;
cin>>n>>q;
for (int i=1;i<=n;i++) {
cin>>x[i];
xx[i]=x[i]*x[i];
x[i]+=x[i-1];
xx[i]+=xx[i-1];
}
cout<<setprecision(6)<<fixed;
for (int i=0;i<q;i++) {
int a,b;
cin>>a>>b;
ld y1=(x[b]-x[a-1])/(b-a+1);
ld y2=(xx[b]-xx[a-1])/(b-a+1);
cout<<y2-y1*y1<<"\n";
}
}