#include <bits/stdc++.h>
using namespace std;
struct segtree {
  int n;
  vector<long double> sum;
  vector<long double> lz_mul;
  vector<long double> lz_sum;
  segtree(int _n) {
    n = _n;
    sum.assign(4 * n + 5, 0.0);
    lz_sum.assign(4 * n + 5, 0.0);
    lz_mul.assign(4 * n + 5, 1.0);
  }
  void push(int id, int l, int r) {
    for (int i = id << 1; i <= (id << 1 | 1); i++) {
      sum[i] *= lz_mul[id];
      lz_mul[i] *= lz_mul[id];
      lz_sum[i] *= lz_mul[id];
    }
    lz_mul[id] = 1.0;
    int mid = (l + r) >> 1;
    sum[id << 1] += (long double)(mid - l + 1) * lz_sum[id];
    sum[id << 1 | 1] += (long double)(r - mid) * lz_sum[id];
    lz_sum[id << 1] += lz_sum[id];
    lz_sum[id << 1 | 1] += lz_sum[id];
    lz_sum[id] = 0;
    sum[id] = sum[id << 1] + sum[id << 1 | 1];
  }
  void update(int id, int l, int r, int u, int v, long double mult_val,
              long double sum_val) {
    if (l > v || r < u) return;
    if (l >= u && r <= v) {
      sum[id] *= mult_val;
      lz_sum[id] *= mult_val;
      lz_mul[id] *= mult_val;
      sum[id] += (r - l + 1) * sum_val;
      lz_sum[id] += sum_val;
      return;
    }
    push(id, l, r);
    int mid = (l + r) >> 1;
    update(id << 1, l, mid, u, v, mult_val, sum_val);
    update(id << 1 | 1, mid + 1, r, u, v, mult_val, sum_val);
    sum[id] = sum[id << 1] + sum[id << 1 | 1];
  }
  void update(int l, int r, long double mult_val, long double sum_val) {
    update(1, 1, n, l, r, mult_val, sum_val);
  }
  long double getsum(int id, int l, int r, int u, int v) {
    if (l > v || r < u) return 0;
    if (l >= u && r <= v) return sum[id];
    push(id, l, r);
    int mid = (l + r) >> 1;
    long double lnode = getsum(id << 1, l, mid, u, v);
    long double rnode = getsum(id << 1 | 1, mid + 1, r, u, v);
    return lnode + rnode;
  }
  long double getsum(int l, int r) { return getsum(1, 1, n, l, r); }
};
const int N = 1e5 + 5;
int n, q;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> n >> q;
  segtree st(n);
  for (int i = 1; i <= n; i++) {
    int x;
    cin >> x;
    st.update(i, i, 1, x);
  }
  while (q--) {
    int t;
    cin >> t;
    if (t == 1) {
      int l, r, u, v;
      cin >> l >> r >> u >> v;
      long double suml = st.getsum(l, r), sumr = st.getsum(u, v);
      long double dv = (long double)(r - l + 1) * (v - u + 1);
      st.update(l, r, (long double)(r - l) / (long double)(r - l + 1),
                sumr / dv);
      st.update(u, v, (long double)(v - u) / (long double)(v - u + 1),
                suml / dv);
    } else {
      int l, r;
      cin >> l >> r;
      cout << fixed << setprecision(6) << st.getsum(l, r) << "\n";
    }
  }
  return 0;
}
