#include <bits/stdc++.h>
using namespace std;
int const N = (1 << 18) + 41;
int n, q;
int l0[N], r0[N], l1[N], r1[N];
int a[N];
int t[N];
long double ans[N];
namespace tree {
long double t[N], las[N], lam[N];
int l, r;
long double val;
void build(int v = 0, int tl = 0, int tr = n - 1) {
  if (tl == tr) {
    las[v] = 0;
    lam[v] = 1;
    t[v] = a[tl];
  } else {
    int tm = (tl + tr) / 2;
    build(v * 2 + 1, tl, tm);
    build(v * 2 + 2, tm + 1, tr);
    t[v] = t[v * 2 + 1] + t[v * 2 + 2];
    las[v] = 0;
    lam[v] = 1;
  }
}
void push(int v, int tl, int tr) {
  int tm = (tl + tr) / 2;
  if (v * 2 + 1 < N) {
    t[v * 2 + 1] *= lam[v];
    t[v * 2 + 1] += las[v] * (tm - tl + 1);
    lam[v * 2 + 1] *= lam[v];
    las[v * 2 + 1] *= lam[v];
    las[v * 2 + 1] += las[v];
  }
  if (v * 2 + 2 < N) {
    t[v * 2 + 2] *= lam[v];
    t[v * 2 + 2] += las[v] * (tr - tm);
    lam[v * 2 + 2] *= lam[v];
    las[v * 2 + 2] *= lam[v];
    las[v * 2 + 2] += las[v];
  }
  lam[v] = 1;
  las[v] = 0;
}
void add(int v = 0, int tl = 0, int tr = n - 1) {
  push(v, tl, tr);
  if (tl > r || l > tr) return;
  if (l <= tl && tr <= r) {
    t[v] += val * (tr - tl + 1);
    las[v] = val;
    return;
  }
  int tm = (tl + tr) / 2;
  add(v * 2 + 1, tl, tm);
  add(v * 2 + 2, tm + 1, tr);
  t[v] = t[v * 2 + 1] + t[v * 2 + 2];
}
void add(int l, int r, long double val) {
  tree::l = l;
  tree::r = r;
  tree::val = val;
  add();
}
void mul(int v = 0, int tl = 0, int tr = n - 1) {
  push(v, tl, tr);
  if (tl > r || l > tr) return;
  if (l <= tl && tr <= r) {
    t[v] *= val;
    lam[v] = val;
    return;
  }
  int tm = (tl + tr) / 2;
  mul(v * 2 + 1, tl, tm);
  mul(v * 2 + 2, tm + 1, tr);
  t[v] = t[v * 2 + 1] + t[v * 2 + 2];
}
void mul(int l, int r, long double val) {
  tree::l = l;
  tree::r = r;
  tree::val = val;
  mul();
}
long double sum(int v, int tl, int tr) {
  push(v, tl, tr);
  if (tl > r || l > tr) return 0;
  if (l <= tl && tr <= r) {
    return t[v];
  }
  int tm = (tl + tr) / 2;
  long double res = sum(v * 2 + 1, tl, tm) + sum(v * 2 + 2, tm + 1, tr);
  t[v] = t[v * 2 + 1] + t[v * 2 + 2];
  return res;
}
long double sum(int l, int r) {
  tree::l = l;
  tree::r = r;
  return sum(0, 0, n - 1);
}
};  // namespace tree
void solve() {
  for (int i = 0; i < q; ++i) {
    --l0[i];
    --r0[i];
    --l1[i];
    --r1[i];
  }
  tree::build();
  for (int i = 0; i < q; ++i) {
    if (t[i] == 1) {
      long double s0 = tree::sum(l0[i], r0[i]);
      long double s1 = tree::sum(l1[i], r1[i]);
      long double len0 = (r0[i] - l0[i] + 1);
      long double len1 = (r1[i] - l1[i] + 1);
      tree::mul(l0[i], r0[i], (len0 - 1) / len0);
      tree::add(l0[i], r0[i], s1 / len0 / len1);
      tree::mul(l1[i], r1[i], (len1 - 1) / len1);
      tree::add(l1[i], r1[i], s0 / len1 / len0);
    } else {
      ans[i] = tree::sum(l0[i], r0[i]);
    }
  }
}
int main() {
  scanf("%d %d", &n, &q);
  for (int i = 0; i < n; ++i) scanf("%d", &a[i]);
  for (int i = 0; i < q; ++i) {
    scanf("%d", &t[i]);
    if (t[i] == 1) {
      scanf("%d %d %d %d", &l0[i], &r0[i], &l1[i], &r1[i]);
    } else {
      scanf("%d %d", &l0[i], &r0[i]);
    }
  }
  solve();
  for (int i = 0; i < q; ++i) {
    if (t[i] == 2) {
      printf("%.15Lf\n", ans[i]);
    }
  }
  return 0;
}
