#include <bits/stdc++.h>
const char en = '\n';
using namespace std;
template <class T, class U>
ostream& operator<<(ostream& out, const pair<T, U>& par) {
  out << par.first << " " << par.second << en;
  return out;
}
template <class T>
ostream& operator<<(ostream& out, const vector<T>& v) {
  for (long long i = 0; i < (long long)(v.size()); i++) {
    if (i) out << " ";
    cout << v[i];
  }
  return out;
}
template <class ValueType>
class SegmentTree {
 private:
  int SIZE;
  int *Left, *Right;
  ValueType *value, *minimum, *maximum;
  ValueType *lazy_add, *lazy_mul_val;
  bool* lazy_mul;
  void clearVertex(int v) {
    if (lazy_mul[v]) {
      value[v] *= lazy_mul_val[v];
      lazy_mul[v] = false;
      if (Left[v] + 1 != Right[v]) {
        lazy_mul[2 * v] = lazy_mul[2 * v + 1] = true;
        lazy_mul_val[2 * v] *= lazy_mul_val[v];
        lazy_add[2 * v] *= lazy_mul_val[v];
        lazy_mul_val[2 * v + 1] *= lazy_mul_val[v];
        lazy_add[2 * v + 1] *= lazy_mul_val[v];
      }
      lazy_mul_val[v] = 1;
    }
    if (lazy_add[v]) {
      value[v] += lazy_add[v] * (Right[v] - Left[v]);
      if (Left[v] + 1 != Right[v]) {
        lazy_add[2 * v] += lazy_add[v];
        lazy_add[2 * v + 1] += lazy_add[v];
      }
      lazy_add[v] = 0;
    }
  }
  ValueType getSum(int v, int l, int r) {
    clearVertex(v);
    if (l == Left[v] && r == Right[v]) return value[v];
    int middle = (Left[v] + Right[v]) / 2;
    if (middle >= r) return getSum(2 * v, l, r);
    if (middle <= l) return getSum(2 * v + 1, l, r);
    return getSum(2 * v, l, middle) + getSum(2 * v + 1, middle, r);
  }
  void add(int v, int l, int r, ValueType val) {
    clearVertex(v);
    if (l == Left[v] && r == Right[v]) {
      lazy_add[v] = val;
      return;
    }
    int middle = (Left[v] + Right[v]) / 2;
    if (middle >= r)
      add(2 * v, l, r, val);
    else if (middle <= l)
      add(2 * v + 1, l, r, val);
    else {
      add(2 * v, l, middle, val);
      add(2 * v + 1, middle, r, val);
    }
    value[v] += (r - l) * val;
  }
  void mulValue(int v, int l, int r, ValueType val) {
    clearVertex(v);
    if (l == Left[v] && r == Right[v]) {
      lazy_mul_val[v] *= val;
      lazy_mul[v] = true;
      return;
    }
    int middle = (Left[v] + Right[v]) / 2;
    if (middle >= r)
      mulValue(2 * v, l, r, val);
    else if (middle <= l)
      mulValue(2 * v + 1, l, r, val);
    else {
      mulValue(2 * v, l, middle, val);
      mulValue(2 * v + 1, middle, r, val);
    }
    value[v] =
        (lazy_mul[2 * v] ? lazy_mul_val[2 * v] * value[2 * v] : value[2 * v]) +
        lazy_add[2 * v] * (Right[2 * v] - Left[2 * v]) +
        (lazy_mul[2 * v + 1] ? lazy_mul_val[2 * v + 1] * value[2 * v + 1]
                             : value[2 * v + 1]) +
        lazy_add[2 * v + 1] * (Right[2 * v + 1] - Left[2 * v + 1]);
  }

 public:
  void init(int len) {
    for (SIZE = 1; SIZE < len; SIZE *= 2)
      ;
    Left = (int*)malloc(sizeof(int) * 2 * SIZE);
    Right = (int*)malloc(sizeof(int) * 2 * SIZE);
    value = (ValueType*)malloc(sizeof(ValueType) * 2 * SIZE);
    lazy_add = (ValueType*)malloc(sizeof(ValueType) * 2 * SIZE);
    lazy_mul_val = (ValueType*)malloc(sizeof(ValueType) * 2 * SIZE);
    lazy_mul = (bool*)malloc(sizeof(bool) * 2 * SIZE);
    Left[1] = 0;
    Right[1] = SIZE;
    for (long long i = (long long)(1); i <= (long long)(SIZE - 1); i++) {
      Left[2 * i] = Left[i];
      Right[2 * i] = (Left[i] + Right[i]) / 2;
      Left[2 * i + 1] = (Left[i] + Right[i]) / 2;
      Right[2 * i + 1] = Right[i];
    }
    for (long long i = 0; i < (long long)(2 * SIZE); i++) {
      value[i] = lazy_add[i] = ValueType();
      lazy_mul[i] = false;
      lazy_mul_val[i] = 1;
    }
  }
  ValueType getSum(int l, int r) {
    if (l == r) return 0;
    return getSum(1, l, r);
  }
  void add(int l, int r, ValueType val) { add(1, l, r, val); }
  void mulValue(int l, int r, ValueType val) { mulValue(1, l, r, val); }
};
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  SegmentTree<long double> S;
  int n, q;
  cin >> n >> q;
  S.init(n + 1);
  vector<long double> V(n + 1, 0);
  for (long long i = 0; i < (long long)(n); i++) {
    int x;
    cin >> x;
    V[i + 1] = x;
    S.add(i + 1, i + 2, x);
  }
  for (long long i = 0; i < (long long)(q); i++) {
    int t;
    cin >> t;
    if (t == 1) {
      int l1, r1, l2, r2;
      cin >> l1 >> r1 >> l2 >> r2;
      long double sum1 = 0, sum2 = 0;
      sum1 = S.getSum(l1, r1 + 1) / (r1 - l1 + 1);
      sum2 = S.getSum(l2, r2 + 1) / (r2 - l2 + 1);
      long double p1 = 1.0 / (r1 - l1 + 1);
      long double p2 = 1.0 / (r2 - l2 + 1);
      S.mulValue(l1, r1 + 1, 1 - p1);
      S.mulValue(l2, r2 + 1, 1 - p2);
      S.add(l1, r1 + 1, p1 * sum2);
      S.add(l2, r2 + 1, p2 * sum1);
    } else {
      int l, r;
      cin >> l >> r;
      cout << setprecision(10) << fixed << S.getSum(l, r + 1) << endl;
    }
  }
}
