#include <bits/stdc++.h>
using namespace std;
double f[4 * 100010], tag_plu[4 * 100010], tag_mul[4 * 100010];
int n, q, a[100010], tp;
void build(int l, int r, int k) {
  tag_mul[k] = 1.0;
  tag_plu[k] = 0.0;
  if (l == r) {
    f[k] = a[l];
    return;
  }
  int mid = l + r >> 1;
  build(l, mid, k << 1);
  build(mid + 1, r, k << 1 ^ 1);
  f[k] = f[k << 1] + f[k << 1 ^ 1];
}
inline void down(int l, int r, int k) {
  if (fabs(tag_mul[k] - 1.0) > 1e-6) {
    double t = tag_mul[k];
    tag_plu[k << 1] *= t;
    tag_mul[k << 1] *= t;
    f[k << 1] *= t;
    tag_plu[k << 1 ^ 1] *= t;
    tag_mul[k << 1 ^ 1] *= t;
    f[k << 1 ^ 1] *= t;
    tag_mul[k] = 1.0;
  }
  if (fabs(tag_plu[k] - 0.0 > 1e-6)) {
    double t = tag_plu[k];
    int mid = l + r >> 1;
    tag_plu[k << 1] += t;
    f[k << 1] += t * (mid - l + 1);
    tag_plu[k << 1 ^ 1] += t;
    f[k << 1 ^ 1] += t * (r - mid);
    tag_plu[k] = 0;
  }
}
double query(int l, int r, int sta, int end, int k) {
  if (sta <= l && end >= r) return f[k];
  down(l, r, k);
  int mid = l + r >> 1;
  double ret = 0;
  if (sta <= mid) ret += query(l, mid, sta, end, k << 1);
  if (end > mid) ret += query(mid + 1, r, sta, end, k << 1 ^ 1);
  return ret;
}
void modify(int l, int r, int sta, int end, double mul, double plu, int k) {
  if (sta <= l && end >= r) {
    f[k] = mul * f[k] + plu * (r - l + 1);
    tag_mul[k] *= mul;
    tag_plu[k] *= mul;
    tag_plu[k] += plu;
    return;
  }
  down(l, r, k);
  int mid = l + r >> 1;
  if (sta <= mid) modify(l, mid, sta, end, mul, plu, k << 1);
  if (end > mid) modify(mid + 1, r, sta, end, mul, plu, k << 1 ^ 1);
  f[k] = (f[k << 1 ^ 1] + f[k << 1]) * tag_mul[k] + tag_plu[k] * (r - l + 1);
}
int main() {
  scanf("%d%d", &n, &q);
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  build(1, n, 1);
  for (int i = 1; i <= q; i++) {
    scanf("%d", &tp);
    if (tp == 1) {
      int l[2], r[2], L[2];
      double sum[2];
      for (int j = 0; j <= 1; j++) scanf("%d%d", &l[j], &r[j]);
      for (int j = 0; j <= 1; j++) {
        L[j] = r[j] - l[j] + 1;
        sum[j] = query(1, n, l[j], r[j], 1);
      }
      for (int j = 0; j <= 1; j++) {
        modify(1, n, l[j], r[j], (double)(L[j] - 1) / L[j],
               sum[j ^ 1] / L[j ^ 1] / L[j], 1);
      }
    } else {
      int l, r;
      scanf("%d%d", &l, &r);
      printf("%.7f\n", query(1, n, l, r, 1));
    }
  }
  return 0;
}
