#include <bits/stdc++.h>
using namespace std;
int n, m, til, a[100005];
class segtree {
 public:
  int son[2];
  double sum, laz, mul;
} c[100005 << 1];
inline int read() {
  char ch = getchar();
  int ret = 0, f = 1;
  while (ch > '9' || ch < '0') {
    if (ch == '-') f = -f;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') ret = ret * 10 + ch - '0', ch = getchar();
  return ret * f;
}
int Build(int l, int r) {
  int now = ++til;
  if (l < r) {
    int mid = (r - l >> 1) + l;
    c[now].son[0] = Build(l, mid);
    c[now].son[1] = Build(mid + 1, r);
    c[now].sum = c[c[now].son[0]].sum + c[c[now].son[1]].sum;
  } else
    c[now].sum = a[l];
  c[now].mul = 1.0;
  return now;
}
inline void Pushdown(int x, int l, int r) {
  if (c[x].mul != 1.0) {
    c[c[x].son[0]].sum *= c[x].mul;
    c[c[x].son[1]].sum *= c[x].mul;
    c[c[x].son[0]].mul *= c[x].mul;
    c[c[x].son[1]].mul *= c[x].mul;
    c[c[x].son[0]].laz *= c[x].mul;
    c[c[x].son[1]].laz *= c[x].mul;
    c[x].mul = 1.0;
  }
  if (c[x].laz != 0.0) {
    int mid = (r - l >> 1) + l;
    c[c[x].son[0]].sum += c[x].laz * (mid - l + 1);
    c[c[x].son[1]].sum += c[x].laz * (r - mid);
    c[c[x].son[0]].laz += c[x].laz;
    c[c[x].son[1]].laz += c[x].laz;
    c[x].laz = 0.0;
  }
}
double Query(int now, int l, int r, int a, int b) {
  Pushdown(now, l, r);
  if (a <= l && b >= r) return c[now].sum;
  int mid = (r - l >> 1) + l;
  double res = 0;
  if (a <= mid) res += Query(c[now].son[0], l, mid, a, b);
  if (b > mid) res += Query(c[now].son[1], mid + 1, r, a, b);
  return res;
}
void Add(int now, int l, int r, int a, int b, double val) {
  Pushdown(now, l, r);
  if (a <= l && b >= r) {
    c[now].sum += val * (r - l + 1);
    c[now].laz += val;
    return;
  }
  int mid = (r - l >> 1) + l;
  if (a <= mid) Add(c[now].son[0], l, mid, a, b, val);
  if (b > mid) Add(c[now].son[1], mid + 1, r, a, b, val);
  c[now].sum = c[c[now].son[0]].sum + c[c[now].son[1]].sum;
}
void Mul(int now, int l, int r, int a, int b, double val) {
  Pushdown(now, l, r);
  if (a <= l && b >= r) {
    c[now].sum *= val;
    c[now].laz *= val;
    c[now].mul *= val;
    return;
  }
  int mid = (r - l >> 1) + l;
  if (a <= mid) Mul(c[now].son[0], l, mid, a, b, val);
  if (b > mid) Mul(c[now].son[1], mid + 1, r, a, b, val);
  c[now].sum = c[c[now].son[0]].sum + c[c[now].son[1]].sum;
}
int main() {
  n = read(), m = read();
  for (int i = 1; i <= n; ++i) a[i] = read();
  Build(1, n);
  while (m--) {
    int typ = read();
    if (typ == 1) {
      int l1 = read(), r1 = read();
      int l2 = read(), r2 = read();
      double len1 = r1 - l1 + 1, len2 = r2 - l2 + 1;
      double sum1 = Query(1, 1, n, l1, r1);
      double sum2 = Query(1, 1, n, l2, r2);
      Mul(1, 1, n, l1, r1, (len1 - 1) / len1);
      Mul(1, 1, n, l2, r2, (len2 - 1) / len2);
      Add(1, 1, n, l1, r1, sum2 / len1 / len2);
      Add(1, 1, n, l2, r2, sum1 / len2 / len1);
    } else {
      int l = read(), r = read();
      printf("%.6lf\n", Query(1, 1, n, l, r));
    }
  }
  return 0;
}
