#include <bits/stdc++.h>
using namespace std;
const int MAX = 1e5 + 9;
const double EPS = 1e-7;
int n, a[MAX];
double tree[(MAX << 2)], lazy[(MAX << 2)][2];
void Build(int low = 1, int high = n, int pos = 1) {
  lazy[pos][0] = 1.0;
  if (low == high) {
    tree[pos] = a[low];
    return;
  }
  int mid = ((low + high) >> 1);
  Build(low, mid, (pos << 1));
  Build(mid + 1, high, (pos << 1 | 1));
  tree[pos] = tree[(pos << 1)] + tree[(pos << 1 | 1)];
}
void Push(int low, int high, int pos) {
  tree[pos] *= lazy[pos][0];
  if (low != high) {
    lazy[(pos << 1)][0] *= lazy[pos][0];
    lazy[(pos << 1 | 1)][0] *= lazy[pos][0];
    lazy[(pos << 1)][1] *= lazy[pos][0];
    lazy[(pos << 1 | 1)][1] *= lazy[pos][0];
  }
  lazy[pos][0] = 1.0;
  tree[pos] += 1.0 * (high - low + 1) * lazy[pos][1];
  if (low != high) {
    lazy[(pos << 1)][1] += lazy[pos][1];
    lazy[(pos << 1 | 1)][1] += lazy[pos][1];
  }
  lazy[pos][1] = 0;
}
void PushAll(int low = 1, int high = 1, int pos = 1) {
  Push(low, high, pos);
  if (low == high) {
    return;
  }
  int mid = ((low + high) >> 1);
  PushAll(low, mid, (pos << 1));
  PushAll(mid + 1, high, (pos << 1 | 1));
  tree[pos] = tree[(pos << 1)] + tree[(pos << 1 | 1)];
}
void Update(bool id, int L, int R, double val, int low = 1, int high = n,
            int pos = 1) {
  if (low == 1 && high == n) {
    PushAll();
  }
  Push(low, high, pos);
  if (L > high || R < low) {
    return;
  }
  if (L <= low && R >= high) {
    if (!id)
      lazy[pos][0] *= val;
    else
      lazy[pos][1] += val;
    Push(low, high, pos);
    return;
  }
  int mid = ((low + high) >> 1);
  Update(id, L, R, val, low, mid, (pos << 1));
  Update(id, L, R, val, mid + 1, high, (pos << 1 | 1));
  tree[pos] = tree[(pos << 1)] + tree[(pos << 1 | 1)];
}
double Query(int L, int R, int low = 1, int high = n, int pos = 1) {
  if (low == 1 && high == n) {
    PushAll();
  }
  Push(low, high, pos);
  if (L > high || R < low) {
    return 0;
  }
  if (L <= low && R >= high) {
    return tree[pos];
  }
  int mid = ((low + high) >> 1);
  return Query(L, R, low, mid, (pos << 1)) +
         Query(L, R, mid + 1, high, (pos << 1 | 1));
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int q;
  cin >> n >> q;
  for (int i = 1; i <= n; ++i) {
    cin >> a[i];
  }
  Build();
  while (q--) {
    int op;
    cin >> op;
    if (op == 1) {
      int L1, R1, L2, R2;
      cin >> L1 >> R1 >> L2 >> R2;
      double sum1 = Query(L1, R1);
      double sum2 = Query(L2, R2);
      Update(0, L1, R1, (double)(R1 - L1) / (double)(R1 - L1 + 1));
      Update(0, L2, R2, (double)(R2 - L2) / (double)(R2 - L2 + 1));
      Update(1, L1, R1,
             1.0 / (double)(R1 - L1 + 1) * (double)1.0 / (double)(R2 - L2 + 1) *
                 sum2);
      Update(1, L2, R2,
             1.0 / (double)(R2 - L2 + 1) * (double)1.0 / (double)(R1 - L1 + 1) *
                 sum1);
    } else {
      int L, R;
      cin >> L >> R;
      cout << setprecision(5) << Query(L, R) << "\n";
    }
  }
  return 0;
}
