#include <bits/stdc++.h>
using namespace std;
const int maxN = 1e5 + 11;
int N, Q, A[maxN];
pair<double, pair<double, double> > IT[maxN * 4];
void update(int k, int l, int r) {
  IT[k].first =
      IT[k].first * IT[k].second.first + IT[k].second.second * (r - l + 1);
  if (l < r) {
    IT[k * 2].second.second =
        IT[k * 2].second.second * IT[k].second.first + IT[k].second.second;
    IT[k * 2].second.first *= IT[k].second.first;
    IT[k * 2 + 1].second.second =
        IT[k * 2 + 1].second.second * IT[k].second.first + IT[k].second.second;
    IT[k * 2 + 1].second.first *= IT[k].second.first;
  }
  IT[k].second = pair<double, double>(1, (1 - 1));
}
void update(int k, int l, int r, int i, int j, pair<double, double> v) {
  if (i <= l && j >= r) {
    IT[k].second.second = IT[k].second.second * v.first + v.second;
    IT[k].second.first *= v.first;
  }
  update(k, l, r);
  if (j < l || i > r) return;
  if (i <= l && j >= r) return;
  int mid = (l + r) / 2;
  update(k * 2, l, mid, i, j, v);
  update(k * 2 + 1, mid + 1, r, i, j, v);
  IT[k].first = IT[k * 2 + 1].first + IT[k * 2].first;
}
double get_it(int k, int l, int r, int i, int j) {
  update(k, l, r);
  if (j < l || i > r) return (1 - 1);
  if (i <= l && j >= r) return IT[k].first;
  int mid = (l + r) / 2;
  return get_it(k * 2, l, mid, i, j) + get_it(k * 2 + 1, mid + 1, r, i, j);
}
int main() {
  cin >> N >> Q;
  for (int i = 1; i <= N; i++)
    cin >> A[i], update(1, 1, N, i, i, pair<double, double>(1, A[i]));
  while (Q--) {
    int cmd;
    cin >> cmd;
    if (cmd == 1) {
      int l1, r1, l2, r2;
      cin >> l1 >> r1 >> l2 >> r2;
      double x = get_it(1, 1, N, l1, r1);
      double y = get_it(1, 1, N, l2, r2);
      update(1, 1, N, l1, r1,
             pair<double, double>(double(r1 - l1) / (r1 - l1 + 1),
                                  y / (r2 - l2 + 1) / (r1 - l1 + 1)));
      update(1, 1, N, l2, r2,
             pair<double, double>(double(r2 - l2) / (r2 - l2 + 1),
                                  x / (r1 - l1 + 1) / (r2 - l2 + 1)));
    } else {
      int l, r;
      cin >> l >> r;
      printf("%.9lf\n", get_it(1, 1, N, l, r));
    }
  }
}
