#include <bits/stdc++.h>
using namespace std;
const int maxn = 1000005;
const double eps = 1e-12;
const long long mod = 1000000009;
int n, Q;
int a[maxn];
double sg[maxn] = {0}, lza[maxn] = {0}, lzm[maxn] = {0};
void pushdown(int o, int l, int r) {
  if (lzm[o] != 1) {
    lzm[o << 1] *= lzm[o];
    lzm[o << 1 | 1] *= lzm[o];
    lza[o << 1] *= lzm[o];
    lza[o << 1 | 1] *= lzm[o];
    sg[o << 1] *= lzm[o];
    sg[o << 1 | 1] *= lzm[o];
    lzm[o] = 1;
  }
  if (lza[o] != 0) {
    lza[o << 1] += lza[o];
    lza[o << 1 | 1] += lza[o];
    int mid = (l + r) >> 1;
    sg[o << 1] += (mid - l) * lza[o];
    sg[o << 1 | 1] += (r - mid) * lza[o];
    lza[o] = 0;
  }
}
void pushup(int o) { sg[o] = sg[o << 1 | 1] + sg[o << 1]; }
void update(int o, int l, int r, int tl, int tr, int op, double x) {
  if (r <= tl || tr <= l) return;
  if (tl <= l && r <= tr) {
    if (op == 1)
      lzm[o] *= x, lza[o] *= x, sg[o] *= x;
    else
      lza[o] += x, sg[o] += (r - l) * x;
    return;
  }
  pushdown(o, l, r);
  int mid = (l + r) >> 1;
  update(o << 1, l, mid, tl, tr, op, x);
  update(o << 1 | 1, mid, r, tl, tr, op, x);
  pushup(o);
}
double query(int o, int l, int r, int tl, int tr) {
  if (r <= tl || tr <= l) return 0;
  if (tl <= l && r <= tr) return sg[o];
  pushdown(o, l, r);
  int mid = (l + r) >> 1;
  return query(o << 1, l, mid, tl, tr) + query(o << 1 | 1, mid, r, tl, tr);
}
int main() {
  int i, j;
  scanf("%d %d", &n, &Q);
  for (i = 0; i < n; i++) scanf("%d", a + i);
  for (i = 0; i < maxn; i++) lzm[i] = 1;
  for (i = 0; i < n; i++) update(1, 0, n, i, i + 1, 0, a[i]);
  while (Q--) {
    int t, l1, r1, l2, r2;
    scanf("%d %d %d", &t, &l1, &r1);
    if (t == 1) scanf("%d %d", &l2, &r2);
    --l1;
    --l2;
    if (t == 1) {
      double s1 = query(1, 0, n, l1, r1), s2 = query(1, 0, n, l2, r2);
      update(1, 0, n, l1, r1, 1, (r1 - l1 - 1.0) / (r1 - l1));
      update(1, 0, n, l1, r1, 0, s2 / (r1 - l1) / (r2 - l2));
      update(1, 0, n, l2, r2, 1, (r2 - l2 - 1.0) / (r2 - l2));
      update(1, 0, n, l2, r2, 0, s1 / (r1 - l1) / (r2 - l2));
    } else {
      printf("%.6lf\n", query(1, 0, n, l1, r1));
    }
  }
  return 0;
}
