#include <bits/stdc++.h>
using namespace std;
inline void read(int &x) {
  char ch;
  bool flag = false;
  for (ch = getchar(); !isdigit(ch); ch = getchar())
    if (ch == '-') flag = true;
  for (x = 0; isdigit(ch); x = x * 10 + ch - '0', ch = getchar())
    ;
  x = flag ? -x : x;
}
inline void read(long long &x) {
  char ch;
  bool flag = false;
  for (ch = getchar(); !isdigit(ch); ch = getchar())
    if (ch == '-') flag = true;
  for (x = 0; isdigit(ch); x = x * 10 + ch - '0', ch = getchar())
    ;
  x = flag ? -x : x;
}
int n, m;
int len[120000 * 7];
double tree[120000 * 7];
double add[120000 * 7], mul[120000 * 7];
int a[120000];
void update(int p) { tree[p] = tree[p * 2] + tree[p * 2 + 1]; }
void build(int p, int l, int r) {
  mul[p] = 1;
  add[p] = 0;
  len[p] = r - l + 1;
  if (l == r) {
    tree[p] = a[l];
    return;
  }
  int mid = (l + r) / 2;
  build(p * 2, l, mid);
  build(p * 2 + 1, mid + 1, r);
  update(p);
}
void pushdown(int p) {
  tree[p * 2] = tree[p * 2] * mul[p] + add[p] * len[p * 2];
  add[p * 2] = add[p * 2] * mul[p] + add[p];
  mul[p * 2] = mul[p * 2] * mul[p];
  tree[p * 2 + 1] = tree[p * 2 + 1] * mul[p] + add[p] * len[p * 2 + 1];
  add[p * 2 + 1] = add[p * 2 + 1] * mul[p] + add[p];
  mul[p * 2 + 1] = mul[p * 2 + 1] * mul[p];
  mul[p] = 1;
  add[p] = 0;
}
void change(int p, int l, int r, int a, int b, double mull, double addd) {
  pushdown(p);
  if ((l == a) && (r == b)) {
    tree[p] = tree[p] * mull + addd * len[p];
    add[p] = add[p] * mull + addd;
    mul[p] = mul[p] * mull;
    return;
  }
  int mid = (l + r) / 2;
  if (b <= mid)
    change(p * 2, l, mid, a, b, mull, addd);
  else if (a > mid)
    change(p * 2 + 1, mid + 1, r, a, b, mull, addd);
  else {
    change(p * 2, l, mid, a, mid, mull, addd);
    change(p * 2 + 1, mid + 1, r, mid + 1, b, mull, addd);
  }
  update(p);
}
double query(int p, int l, int r, int a, int b) {
  if ((l == a) && (r == b)) return tree[p];
  pushdown(p);
  int mid = (l + r) / 2;
  if (b <= mid)
    return query(p * 2, l, mid, a, b);
  else if (a > mid)
    return query(p * 2 + 1, mid + 1, r, a, b);
  else
    return query(p * 2, l, mid, a, mid) +
           query(p * 2 + 1, mid + 1, r, mid + 1, b);
}
int main() {
  read(n);
  read(m);
  for (int i = 1; i <= n; i++) read(a[i]);
  build(1, 1, n);
  for (int i = 1; i <= m; i++) {
    int op;
    read(op);
    if (op == 1) {
      int l1, r1, l2, r2;
      read(l1);
      read(r1);
      read(l2);
      read(r2);
      double t1 = query(1, 1, n, l1, r1);
      double t2 = query(1, 1, n, l2, r2);
      change(1, 1, n, l1, r1, 1.0 * (r1 - l1) / (r1 - l1 + 1),
             t2 / (r2 - l2 + 1) / (r1 - l1 + 1));
      change(1, 1, n, l2, r2, 1.0 * (r2 - l2) / (r2 - l2 + 1),
             t1 / (r1 - l1 + 1) / (r2 - l2 + 1));
    } else {
      int l, r;
      read(l);
      read(r);
      printf("%.6f\n", query(1, 1, n, l, r));
    }
  }
}
