#include <bits/stdc++.h>
using namespace std;
const int maxn = 100050;
const double eps = 1e-6;
double a[maxn], sum[maxn << 2];
double addv[maxn << 2], multv[maxn << 2];
int dcmp(double x) {
  if (fabs(x) < eps) return 0;
  return (x < 0 ? -1 : 1);
}
void push_up(int p) { sum[p] = sum[p << 1] + sum[p << 1 | 1]; }
void push_down(int p, int l, int r) {
  if (dcmp(multv[p]) != 1 || dcmp(addv[p]) != 0) {
    multv[p << 1] *= multv[p];
    multv[p << 1 | 1] *= multv[p];
    addv[p << 1] = multv[p] * addv[p << 1] + addv[p];
    addv[p << 1 | 1] = multv[p] * addv[p << 1 | 1] + addv[p];
    int mid = (l + r) >> 1;
    sum[p << 1] = multv[p] * sum[p << 1] + addv[p] * (mid - l + 1);
    sum[p << 1 | 1] = multv[p] * sum[p << 1 | 1] + addv[p] * (r - mid);
    multv[p] = 1;
    addv[p] = 0;
  }
}
void build(int p, int l, int r) {
  multv[p] = 1;
  addv[p] = 0;
  if (l == r) {
    sum[p] = a[l];
    return;
  }
  int mid = (l + r) >> 1;
  build(p << 1, l, mid);
  build(p << 1 | 1, mid + 1, r);
  push_up(p);
}
void modify(int p, int l, int r, int L, int R, double k, double b) {
  if (L <= l && r <= R) {
    sum[p] = k * sum[p] + b * (r - l + 1);
    multv[p] *= k;
    addv[p] = k * addv[p] + b;
    return;
  }
  push_down(p, l, r);
  int mid = (l + r) >> 1;
  if (L <= mid) modify(p << 1, l, mid, L, R, k, b);
  if (R > mid) modify(p << 1 | 1, mid + 1, r, L, R, k, b);
  push_up(p);
}
double query(int p, int l, int r, int L, int R) {
  if (L <= l && r <= R) return sum[p];
  push_down(p, l, r);
  double ret = 0;
  int mid = (l + r) >> 1;
  if (L <= mid) ret += query(p << 1, l, mid, L, R);
  if (R > mid) ret += query(p << 1 | 1, mid + 1, r, L, R);
  return ret;
}
int main() {
  int n, q;
  scanf("%d%d", &n, &q);
  for (int i = 1; i <= n; i++) scanf("%lf", &a[i]);
  build(1, 1, n);
  while (q--) {
    int op, l1, r1, l2, r2;
    scanf("%d", &op);
    if (op == 1) {
      scanf("%d%d%d%d", &l1, &r1, &l2, &r2);
      double size1 = r1 - l1 + 1, size2 = r2 - l2 + 1;
      double t1 = query(1, 1, n, l1, r1), t2 = query(1, 1, n, l2, r2);
      modify(1, 1, n, l1, r1, (size1 - 1) / size1, t2 / (size2 * size1));
      modify(1, 1, n, l2, r2, (size2 - 1) / size2, t1 / (size1 * size2));
    } else {
      scanf("%d%d", &l1, &l2);
      double ans = query(1, 1, n, l1, l2);
      printf("%f\n", ans);
    }
  }
  return 0;
}
