#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 9;
int n, m;
struct tree {
  double tot, ad, mul;
} tr[N << 2];
long long a[N];
void build(int now, int l, int r) {
  tr[now].ad = 0, tr[now].mul = 1;
  if (l == r) {
    tr[now].tot = a[l];
    return;
  }
  int mid = (l + r) / 2;
  build(now * 2, l, mid);
  build(now * 2 + 1, mid + 1, r);
  tr[now].tot = tr[now * 2].tot + tr[now * 2 + 1].tot;
}
void pushdown(int now, int l, int r) {
  int mid = (l + r) / 2;
  tr[now * 2].tot = tr[now].mul * tr[now * 2].tot + tr[now].ad * (mid - l + 1);
  tr[now * 2 + 1].tot =
      tr[now].mul * tr[now * 2 + 1].tot + tr[now].ad * (r - mid);
  tr[2 * now].mul *= tr[now].mul, tr[2 * now + 1].mul *= tr[now].mul;
  tr[2 * now].ad = tr[2 * now].ad * tr[now].mul + tr[now].ad;
  tr[2 * now + 1].ad = tr[2 * now + 1].ad * tr[now].mul + tr[now].ad;
  tr[now].mul = 1, tr[now].ad = 0;
}
void pls(int now, int lx, int rx, int l, int r, double d) {
  if (r < lx || l > rx) return;
  if (l <= lx && r >= rx) {
    tr[now].ad += d, tr[now].tot += (rx - lx + 1) * d;
    return;
  }
  pushdown(now, lx, rx);
  int mid = (lx + rx) / 2;
  pls(now * 2, lx, mid, l, r, d);
  pls(now * 2 + 1, mid + 1, rx, l, r, d);
  tr[now].tot = tr[now * 2].tot + tr[now * 2 + 1].tot;
}
void mulm(int now, int lx, int rx, int l, int r, double d) {
  if (r < lx || l > rx) return;
  if (l <= lx && r >= rx) {
    tr[now].mul *= d, tr[now].tot *= d, tr[now].ad *= d;
    return;
  }
  pushdown(now, lx, rx);
  int mid = (lx + rx) / 2;
  mulm(now * 2, lx, mid, l, r, d);
  mulm(now * 2 + 1, mid + 1, rx, l, r, d);
  tr[now].tot = tr[now * 2].tot + tr[now * 2 + 1].tot;
}
double query(int now, int lx, int rx, int l, int r) {
  if (r < lx || l > rx) return 0;
  if (rx <= r && lx >= l) return tr[now].tot;
  pushdown(now, lx, rx);
  int mid = (lx + rx) / 2;
  double ans =
      query(now * 2, lx, mid, l, r) + query(now * 2 + 1, mid + 1, rx, l, r);
  return ans;
}
signed main(int argc, char** argv) {
  int n, q;
  cin >> n >> q;
  for (int i = 1; i <= n; i++) cin >> a[i];
  build(1, 1, n);
  while (q--) {
    int op;
    cin >> op;
    if (op == 1) {
      int l1, r1, l2, r2;
      cin >> l1 >> r1 >> l2 >> r2;
      double x = query(1, 1, n, l1, r1), y = query(1, 1, n, l2, r2),
             ave1 = x / (double)(r1 - l1 + 1), ave2 = y / (double)(r2 - l2 + 1);
      mulm(1, 1, n, l1, r1, 1.0 - 1 / (double)(r1 - l1 + 1));
      mulm(1, 1, n, l2, r2, 1.0 - 1 / (double)(r2 - l2 + 1));
      pls(1, 1, n, l1, r1, ave2 / (double)(r1 - l1 + 1)),
          pls(1, 1, n, l2, r2, ave1 / (double)(r2 - l2 + 1));
    } else {
      int l, r;
      cin >> l >> r;
      printf("%.10lf\n", query(1, 1, n, l, r));
    }
  }
  return 0;
}
