#include <bits/stdc++.h>
using namespace std;
const double eps = 1e-8;
double sg[100005 << 2];
double mtag[100005 << 2];
double ptag[100005 << 2];
double in[100005];
void build(int l, int r, int x) {
  if (l == r) return sg[x] = in[l], mtag[x] = 1, ptag[x] = 0, void();
  int m = l + r >> 1;
  build(l, m, (x + x + 1));
  build(m + 1, r, (x + x + 2));
  sg[x] = sg[(x + x + 1)] + sg[(x + x + 2)];
  mtag[x] = 1;
  ptag[x] = 0;
}
void push(int l, int r, int x, int i = 1) {
  if (l != r) {
    if (fabs(mtag[x] - 1) > eps) {
      sg[(x + x + 1)] *= mtag[x];
      sg[(x + x + 2)] *= mtag[x];
      mtag[(x + x + 1)] *= mtag[x];
      mtag[(x + x + 2)] *= mtag[x];
      ptag[(x + x + 1)] *= mtag[x];
      ptag[(x + x + 2)] *= mtag[x];
      mtag[x] = 1;
    }
    if (fabs(ptag[x]) > eps) {
      int m = l + r >> 1;
      sg[(x + x + 1)] += ptag[x] * (m - l + 1);
      sg[(x + x + 2)] += ptag[x] * (r - m);
      ptag[(x + x + 1)] += ptag[x];
      ptag[(x + x + 2)] += ptag[x];
      ptag[x] = 0;
    }
  }
}
void modify1(int l, int r, int ql, int qr, int x, double mul) {
  push(l, r, x);
  if (r < ql || l > qr) return;
  if (ql <= l && r <= qr) return sg[x] *= mul, mtag[x] *= mul, void();
  int m = l + r >> 1;
  modify1(l, m, ql, qr, (x + x + 1), mul);
  modify1(m + 1, r, ql, qr, (x + x + 2), mul);
  sg[x] = sg[(x + x + 1)] + sg[(x + x + 2)];
}
void modify2(int l, int r, int ql, int qr, int x, double pus) {
  push(l, r, x);
  if (r < ql || l > qr) return;
  if (ql <= l && r <= qr)
    return sg[x] += pus * (r - l + 1), ptag[x] += pus, void();
  int m = l + r >> 1;
  modify2(l, m, ql, qr, (x + x + 1), pus);
  modify2(m + 1, r, ql, qr, (x + x + 2), pus);
  sg[x] = sg[(x + x + 1)] + sg[(x + x + 2)];
}
double query(int l, int r, int ql, int qr, int x) {
  push(l, r, x);
  if (r < ql || l > qr) return 0;
  if (ql <= l && r <= qr) return sg[x];
  int m = l + r >> 1;
  return query(l, m, ql, qr, (x + x + 1)) +
         query(m + 1, r, ql, qr, (x + x + 2));
}
void brute(int l, int r, int x) {
  if (l != r) {
    push(l, r, x);
    int m = l + r >> 1;
    brute(l, m, (x + x + 1));
    brute(m + 1, r, (x + x + 2));
  }
}
int main() {
  {
    cin.tie(0);
    ios_base::sync_with_stdio(false);
  };
  int n, q, cmd, l1, r1, l2, r2;
  cin >> n >> q;
  for (int i = 1; i <= n; i++) cin >> in[i];
  build(1, n, 0);
  while (q--) {
    cin >> cmd;
    if (cmd == 1) {
      cin >> l1 >> r1 >> l2 >> r2;
      double pp = query(1, n, l2, r2, 0) / (r2 - l2 + 1) / (r1 - l1 + 1);
      double pp2 = query(1, n, l1, r1, 0) / (r2 - l2 + 1) / (r1 - l1 + 1);
      modify1(1, n, l1, r1, 0, (r1 - l1) * 1.0 / (r1 - l1 + 1));
      modify2(1, n, l1, r1, 0, pp);
      modify1(1, n, l2, r2, 0, (r2 - l2) * 1.0 / (r2 - l2 + 1));
      modify2(1, n, l2, r2, 0, pp2);
    } else {
      cin >> l1 >> r1;
      cout << fixed << setprecision(15) << query(1, n, l1, r1, 0) << '\n';
    }
  }
  return 0;
}
