#include <bits/stdc++.h>
using namespace std;
int n, q, segsiz;
double Segtree[270000];
double lazymult[270000];
double lazyadd[270000];
double querySeg(int node, int from, int to, int l, int r) {
  if (from > to || to < l || from > r) {
    return 0;
  }
  if (abs(0 - lazyadd[node]) > 0.00001 || abs(1 - lazymult[node]) > 0.00001) {
    if (from != to) {
      lazyadd[node * 2] = lazyadd[node * 2] * lazymult[node] + lazyadd[node];
      lazyadd[node * 2 + 1] =
          lazyadd[node * 2 + 1] * lazymult[node] + lazyadd[node];
      lazymult[node * 2] = lazymult[node * 2] * lazymult[node];
      lazymult[node * 2 + 1] = lazymult[node * 2 + 1] * lazymult[node];
    }
    Segtree[node] =
        (Segtree[node] * lazymult[node]) + (to - from + 1) * lazyadd[node];
    lazyadd[node] = 0;
    lazymult[node] = 1;
  }
  if (from >= l && to <= r) {
    return Segtree[node];
  }
  int mid = (from + to) / 2;
  double ans = querySeg(node * 2, from, mid, l, r);
  ans += querySeg(node * 2 + 1, mid + 1, to, l, r);
  return ans;
}
double updateSeg(int node, int from, int to, int l, int r, double mult,
                 double add) {
  if (from > to || to < l || from > r) {
    return 0;
  }
  if (abs(0.0 - lazyadd[node]) > 0.00001 ||
      abs(1.0 - lazymult[node]) > 0.00001) {
    if (from != to) {
      lazyadd[node * 2] = lazyadd[node * 2] * lazymult[node] + lazyadd[node];
      lazyadd[node * 2 + 1] =
          lazyadd[node * 2 + 1] * lazymult[node] + lazyadd[node];
      lazymult[node * 2] = lazymult[node * 2] * lazymult[node];
      lazymult[node * 2 + 1] = lazymult[node * 2 + 1] * lazymult[node];
    }
    Segtree[node] =
        (Segtree[node] * lazymult[node]) + (to - from + 1) * lazyadd[node];
    lazyadd[node] = 0;
    lazymult[node] = 1;
  }
  if (from >= l && to <= r) {
    lazymult[node] = mult;
    lazyadd[node] = add;
    return Segtree[node] * lazymult[node] + (to - from + 1) * lazyadd[node] -
           Segtree[node];
  }
  int mid = (from + to) / 2;
  double diff = 0;
  diff += updateSeg(node * 2, from, mid, l, r, mult, add);
  diff += updateSeg(node * 2 + 1, mid + 1, to, l, r, mult, add);
  Segtree[node] += diff;
  return diff;
}
double query(int l, int r) {
  return querySeg(1, segsiz, segsiz * 2 - 1, l + segsiz - 1, r + segsiz - 1);
}
void update(int l1, int r1, int l2, int r2) {
  double val1 = (query(l1, r1)) / (r1 - l1 + 1);
  double val2 = (query(l2, r2)) / (r2 - l2 + 1);
  updateSeg(1, segsiz, segsiz * 2 - 1, l2 + segsiz - 1, r2 + segsiz - 1,
            ((double)(r2 - l2)) / (r2 - l2 + 1), val1 / (r2 - l2 + 1));
  updateSeg(1, segsiz, segsiz * 2 - 1, l1 + segsiz - 1, r1 + segsiz - 1,
            ((double)(r1 - l1)) / (r1 - l1 + 1), val2 / (r1 - l1 + 1));
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> n >> q;
  cout << setprecision(15);
  segsiz = 1;
  while (segsiz < n) {
    segsiz *= 2;
  }
  for (int i = 0; i < n; i++) {
    cin >> Segtree[segsiz + i];
  }
  for (int i = 0; i <= 2 * segsiz; i++) {
    lazymult[i] = 1;
  }
  for (int i = segsiz - 1; i >= 1; i--) {
    Segtree[i] = Segtree[2 * i] + Segtree[2 * i + 1];
  }
  for (int Q = 0; Q < q; Q++) {
    int t;
    cin >> t;
    if (t == 1) {
      int l1, r1, l2, r2;
      cin >> l1 >> r1 >> l2 >> r2;
      update(l1, r1, l2, r2);
    } else {
      int l, r;
      cin >> l >> r;
      cout << query(l, r) << "\n";
    }
  }
  return 0;
}
