#include <bits/stdc++.h>
using namespace std;
int n, q, nc, root;
double a[200005], sm[400005];
bool islazy[400005];
double lazymul[400005], lazyadd[400005];
int lc[400005], rc[400005];
int _build(int l, int r) {
  int id = ++nc;
  if (l == r) {
    sm[id] = a[l];
  } else {
    int mid = (l + r) / 2;
    lc[id] = _build(l, mid);
    rc[id] = _build(mid + 1, r);
    sm[id] = sm[lc[id]] + sm[rc[id]];
  }
  islazy[id] = false;
  lazymul[id] = 1;
  lazyadd[id] = 0;
  return id;
}
void _applylazy(int id, int l, int r) {
  if (islazy[id]) {
    sm[id] *= lazymul[id];
    sm[id] += lazyadd[id] * (r - l + 1);
    if (l < r) {
      islazy[lc[id]] = true;
      lazymul[lc[id]] *= lazymul[id];
      lazyadd[lc[id]] *= lazymul[id];
      lazyadd[lc[id]] += lazyadd[id];
      islazy[rc[id]] = true;
      lazymul[rc[id]] *= lazymul[id];
      lazyadd[rc[id]] *= lazymul[id];
      lazyadd[rc[id]] += lazyadd[id];
    }
    islazy[id] = false;
    lazymul[id] = 1;
    lazyadd[id] = 0;
  }
}
void _update(int id, int l, int r, int ul, int ur, double umul, double uadd) {
  _applylazy(id, l, r);
  if (ur < l || r < ul) {
    return;
  }
  if (ul <= l && r <= ur) {
    islazy[id] = true;
    lazymul[id] *= umul;
    lazyadd[id] *= umul;
    lazyadd[id] += uadd;
    _applylazy(id, l, r);
    return;
  }
  int mid = (l + r) / 2;
  _update(lc[id], l, mid, ul, ur, umul, uadd);
  _update(rc[id], mid + 1, r, ul, ur, umul, uadd);
  sm[id] = sm[lc[id]] + sm[rc[id]];
  return;
}
double _query(int id, int l, int r, int ql, int qr) {
  _applylazy(id, l, r);
  if (qr < l || r < ql) {
    return 0;
  }
  if (ql <= l && r <= qr) {
    return sm[id];
  }
  int mid = (l + r) / 2;
  double q1 = _query(lc[id], l, mid, ql, qr);
  double q2 = _query(rc[id], mid + 1, r, ql, qr);
  return q1 + q2;
}
void build(int n) {
  nc = 0;
  root = _build(1, n);
}
void update(int ul, int ur, double umul, double uadd) {
  _update(root, 1, n, ul, ur, umul, uadd);
}
double query(int ql, int qr) { return _query(root, 1, n, ql, qr); }
int main() {
  scanf("%d%d", &n, &q);
  for (int i = 1; i <= n; i++) {
    scanf("%lf", &a[i]);
  }
  build(n);
  for (int i = 1; i <= q; i++) {
    int mode;
    scanf("%d", &mode);
    if (mode == 1) {
      int l1, r1, l2, r2;
      scanf("%d%d%d%d", &l1, &r1, &l2, &r2);
      double e1 = query(l1, r1) / (r1 - l1 + 1);
      double e2 = query(l2, r2) / (r2 - l2 + 1);
      update(l1, r1, (double)(r1 - l1) / (r1 - l1 + 1), e2 / (r1 - l1 + 1));
      update(l2, r2, (double)(r2 - l2) / (r2 - l2 + 1), e1 / (r2 - l2 + 1));
    } else {
      int l, r;
      scanf("%d%d", &l, &r);
      printf("%.10lf\n", query(l, r));
    }
  }
  return 0;
}
