#include <bits/stdc++.h>
using namespace std;
int read() {
  int x = 0, f = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = (x << 3) + (x << 1) + (ch ^ 48);
    ch = getchar();
  }
  return x * f;
}
int n, q, a[200005];
struct Segment_Tree {
  int L[200005 << 2], R[200005 << 2];
  double v[200005 << 2], add[200005 << 2], mul[200005 << 2];
  void pushup(int k) { v[k] = v[k << 1] + v[k << 1 | 1]; }
  void build(int l, int r, int k) {
    add[k] = 0;
    mul[k] = 1;
    L[k] = l;
    R[k] = r;
    if (l == r) {
      v[k] = a[l];
      return;
    }
    int mid = (l + r) >> 1;
    build(l, mid, k << 1);
    build(mid + 1, r, k << 1 | 1);
    pushup(k);
  }
  void pushdown(int k) {
    v[k << 1] *= mul[k];
    v[k << 1 | 1] *= mul[k];
    mul[k << 1] *= mul[k];
    mul[k << 1 | 1] *= mul[k];
    add[k << 1] *= mul[k];
    add[k << 1 | 1] *= mul[k];
    v[k << 1] += (R[k << 1] - L[k << 1] + 1) * add[k];
    v[k << 1 | 1] += (R[k << 1 | 1] - L[k << 1 | 1] + 1) * add[k];
    add[k << 1] += add[k];
    add[k << 1 | 1] += add[k];
    add[k] = 0;
    mul[k] = 1;
  }
  void modify_add(int l, int r, int k, int x, int y, double val) {
    if (l >= x && r <= y) {
      v[k] += (R[k] - L[k] + 1) * val;
      add[k] += val;
      return;
    }
    int mid = (l + r) >> 1;
    pushdown(k);
    if (x <= mid) modify_add(l, mid, k << 1, x, y, val);
    if (y > mid) modify_add(mid + 1, r, k << 1 | 1, x, y, val);
    pushup(k);
  }
  void modify_mul(int l, int r, int k, int x, int y, double val) {
    if (l >= x && r <= y) {
      v[k] *= val;
      mul[k] *= val;
      add[k] *= val;
      return;
    }
    int mid = (l + r) >> 1;
    pushdown(k);
    if (x <= mid) modify_mul(l, mid, k << 1, x, y, val);
    if (y > mid) modify_mul(mid + 1, r, k << 1 | 1, x, y, val);
    pushup(k);
  }
  double query(int l, int r, int k, int x, int y) {
    if (l >= x && r <= y) return v[k];
    int mid = (l + r) >> 1;
    double res = 0;
    pushdown(k);
    if (x <= mid) res += query(l, mid, k << 1, x, y);
    if (y > mid) res += query(mid + 1, r, k << 1 | 1, x, y);
    return res;
  }
} T;
int main() {
  n = read();
  q = read();
  for (int i = 1; i <= n; i++) a[i] = read();
  T.build(1, n, 1);
  while (q--) {
    int opt = read();
    if (opt == 1) {
      int L1 = read(), R1 = read(), L2 = read(), R2 = read();
      double sum1 = T.query(1, n, 1, L1, R1), sum2 = T.query(1, n, 1, L2, R2);
      T.modify_mul(1, n, 1, L1, R1, 1.0 * (R1 - L1) / (R1 - L1 + 1));
      T.modify_add(1, n, 1, L1, R1,
                   1.0 * sum2 / ((double)(R2 - L2 + 1) * (R1 - L1 + 1)));
      T.modify_mul(1, n, 1, L2, R2, 1.0 * (R2 - L2) / (R2 - L2 + 1));
      T.modify_add(1, n, 1, L2, R2,
                   1.0 * sum1 / ((double)(R2 - L2 + 1) * (R1 - L1 + 1)));
    } else {
      int L = read(), R = read();
      printf("%.10lf\n", T.query(1, n, 1, L, R));
    }
  }
  return 0;
}
