#include <bits/stdc++.h>
using namespace std;
const long long MAXN = 200005;
using ld = long double;
long long n, q;
long long a[MAXN];
ld IT[MAXN * 4], lazyadd[MAXN * 4], lazymul[MAXN * 4];
void build(long long l, long long r, long long id) {
  if (l == r) {
    IT[id] = a[l];
    lazymul[id] = 1;
    lazyadd[id] = 0;
    return;
  }
  long long mid = l + r >> 1;
  build(l, mid, id << 1);
  build(mid + 1, r, id << 1 | 1);
  IT[id] = IT[id << 1] + IT[id << 1 | 1];
  lazymul[id] = 1;
  lazyadd[id] = 0;
}
void push(long long id, long long l, long long r) {
  IT[id] = IT[id] * lazymul[id] + lazyadd[id] * (r - l + 1);
  if (l != r) {
    lazymul[id * 2] *= lazymul[id];
    lazyadd[id * 2] = lazyadd[id * 2] * lazymul[id] + lazyadd[id];
    lazymul[id * 2 + 1] *= lazymul[id];
    lazyadd[id * 2 + 1] = lazyadd[id * 2 + 1] * lazymul[id] + lazyadd[id];
  }
  lazymul[id] = 1;
  lazyadd[id] = 0;
}
void upd(long long u, long long v, ld mul, ld add, long long id = 1,
         long long l = 1, long long r = n) {
  push(id, l, r);
  if (r < u || l > v) return;
  if (l >= u && r <= v) {
    IT[id] = IT[id] * mul + add * (r - l + 1);
    if (l != r) {
      lazymul[id * 2] *= mul;
      lazyadd[id * 2] = lazyadd[id * 2] * mul + add;
      lazymul[id * 2 + 1] *= mul;
      lazyadd[id * 2 + 1] = lazyadd[id * 2 + 1] * mul + add;
    }
    return;
  }
  long long mid = l + r >> 1;
  upd(u, v, mul, add, id << 1, l, mid);
  upd(u, v, mul, add, id << 1 | 1, mid + 1, r);
  IT[id] = IT[id << 1] + IT[id << 1 | 1];
}
ld get_sum(long long u, long long v, long long id = 1, long long l = 1,
           long long r = n) {
  push(id, l, r);
  if (r < u || l > v) return 0;
  if (l >= u && r <= v) return IT[id];
  long long mid = l + r >> 1;
  return get_sum(u, v, id << 1, l, mid) +
         get_sum(u, v, id << 1 | 1, mid + 1, r);
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> q;
  for (long long i = 1; i <= n; i++) cin >> a[i];
  build(1, n, 1);
  while (q--) {
    long long t;
    cin >> t;
    if (t == 1) {
      long long l1, r1, l2, r2;
      cin >> l1 >> r1 >> l2 >> r2;
      ld s1 = get_sum(l1, r1) / (ld)(r1 - l1 + 1),
         s2 = get_sum(l2, r2) / (ld)(r2 - l2 + 1);
      upd(l1, r1, (ld)(r1 - l1) / (ld)(r1 - l1 + 1),
          (ld)s2 / (ld)(r1 - l1 + 1));
      upd(l2, r2, (ld)(r2 - l2) / (ld)(r2 - l2 + 1),
          (ld)s1 / (ld)(r2 - l2 + 1));
    } else {
      long long l, r;
      cin >> l >> r;
      cout << setprecision(10) << fixed << get_sum(l, r) << '\n';
    }
  }
}
