#include <bits/stdc++.h>
#define endl '\n'
using namespace std;
const int N = 2e5+5;
struct node{
double s,c;
double sum;
int lazy;
}t[N<<2];
int n,a[N];
inline void pushDown(int k,int mid,int l,int r){
if(!t[k].lazy) return;
t[k<<1].s = t[k<<1].s*cos(t[k].lazy*(mid-l+1)) + t[k<<1].c*sin(t[k].lazy*(mid-l+1));
t[k<<1].c = t[k<<1].c*cos(t[k].lazy*(mid-l+1)) - t[k<<1].s*sin(t[k].lazy*(mid-l+1));
t[k<<1].lazy += t[k].lazy;
t[k<<1|1].s = t[k<<1|1].s*cos(t[k].lazy*(r-mid)) + t[k<<1|1].c*sin(t[k].lazy*(r-mid));
t[k<<1|1].c = t[k<<1|1].c*cos(t[k].lazy*(r-mid)) - t[k<<1|1].s*sin(t[k].lazy*(r-mid));
t[k<<1|1].lazy += t[k].lazy;
t[k].lazy = 0;
}
inline void build(int k,int l,int r){
if(l == r){
t[k].s = sin(a[l]);
t[k].c = cos(a[l]);
return;
}
int mid = l + r >> 1;
build(k<<1,l,mid);
build(k<<1|1,mid+1,r);
t[k].s = t[k<<1].s + t[k<<1|1].s;
t[k].c = t[k<<1].c + t[k<<1|1].c;
}
inline void update(int k,int l,int r,int x,int y,int z){
if(x <= l && r <= y){
t[k].s = t[k].s*cos(z*(r-l+1)) + t[k].c*sin(z*(r-l+1));
t[k].c = t[k].c*cos(z*(r-l+1)) - t[k].s*sin(z*(r-l+1));
t[k].lazy += z;
return;
}
int mid = l + r >> 1;
pushDown(k,mid,l,r);
if(x <= mid) update(k<<1,l,mid,x,y,z);
if(y > mid) update(k<<1|1,mid+1,r,x,y,z);
t[k].s = t[k<<1].s + t[k<<1|1].s;
t[k].c = t[k<<1].c + t[k<<1|1].c;
}
inline double query(int k,int l,int r,int x,int y){
if(x <= l && r <= y)
return t[k].s;
int mid = l + r >> 1;
double res = 0;
pushDown(k,mid,l,r);
if(x <= mid) res += query(k<<1,l,mid,x,y);
if(y > mid) res += query(k<<1|1,mid+1,r,x,y);
return res;
}
signed main(){
scanf("%d",&n);
for(int i = 1; i <= n; i++)
scanf("%d",&a[i]);
build(1,1,n);
int T,op,l,r,v;
scanf("%d",&T);
while(T--){
scanf("%d%d%d",&op,&l,&r);
if(op == 1){
scanf("%d",&v);
update(1,1,n,l,r,v);
}else printf("%.1lf\n",query(1,1,n,l,r));
}
return 0;
}