#include <bits/stdc++.h>
template <typename T>
inline void read(T &x) {
  char c;
  bool neg = false;
  while (!isdigit(c = getchar()) && c != '-')
    ;
  x = 0;
  if (c == '-') {
    neg = true;
    c = getchar();
  }
  do {
    x = x * 10 + c - '0';
  } while (isdigit(c = getchar()));
  if (neg) x = -x;
}
template <typename T>
inline void write(T x) {
  if (x < 0) {
    putchar('-');
    write(-x);
    return;
  }
  if (x < 10) {
    putchar(char(x + 48));
  } else {
    write(x / 10);
    putchar(char(48 + x % 10));
  }
}
template <typename T>
inline void writeln(T x) {
  write(x);
  putchar('\n');
}
using namespace std;
struct Data {
  double sum, product;
};
long long a[1001000];
void operator+=(Data &a, const Data &b) {
  if (b.product != 1) {
    a.product *= b.product;
    a.sum = a.sum * b.product;
  }
  if (b.sum != 0) a.sum += b.sum;
}
double IT[1001000];
Data lazy[1001000];
struct sIT {
  int n;
  void Build(int n) {
    this->n = n;
    Build(1, 1, n);
  }
  void Up(int l, int r, Data val) { Up(1, 1, n, l, r, val); }
  double Get(int l, int r) { return Get(1, 1, n, l, r); }

 private:
  void Build(int k, int l, int r) {
    if (l == r) {
      IT[k] = a[l];
      lazy[k].sum = 0;
      lazy[k].product = 1;
      return;
    }
    int m = (l + r) >> 1;
    Build(k * 2, l, m);
    Build(k * 2 + 1, m + 1, r);
    IT[k] = IT[k * 2] + IT[k * 2 + 1];
    lazy[k].sum = 0;
    lazy[k].product = 1;
  }
  void Down(int k, int l, int r) {
    int m = (l + r) >> 1;
    lazy[k * 2] += lazy[k];
    lazy[k * 2 + 1] += lazy[k];
    if (lazy[k].product != 1) {
      IT[k * 2] *= lazy[k].product;
      IT[k * 2 + 1] *= lazy[k].product;
    }
    if (lazy[k].sum != 0) {
      IT[k * 2] += lazy[k].sum * (m - l + 1);
      IT[k * 2 + 1] += lazy[k].sum * (r - m);
    }
    lazy[k].product = 1;
    lazy[k].sum = 0;
  }
  void Up(int k, int l, int r, int u, int v, Data val) {
    if (l > v || r < u) return;
    if (u <= l && r <= v) {
      if (val.product != 1) IT[k] *= val.product;
      if (val.sum != 0) IT[k] += val.sum * (r - l + 1);
      lazy[k] += val;
      return;
    }
    Down(k, l, r);
    int m = (l + r) >> 1;
    Up(k * 2, l, m, u, v, val);
    Up(k * 2 + 1, m + 1, r, u, v, val);
    IT[k] = IT[k * 2] + IT[k * 2 + 1];
  }
  double Get(int k, int l, int r, int u, int v) {
    if (l > v || r < u) return 0;
    if (u <= l && r <= v) return IT[k];
    Down(k, l, r);
    int m = (l + r) >> 1;
    return Get(k * 2, l, m, u, v) + Get(k * 2 + 1, m + 1, r, u, v);
  }
} ITT;
int n, q, c, l1, l2, r2, r1;
int main() {
  cin.tie(NULL);
  cout.tie(NULL);
  ;
  read(n);
  read(q);
  for (int i = 1; i <= n; i++) {
    read(a[i]);
  }
  ITT.Build(n);
  while (q--) {
    read(c);
    if (c == 1) {
      read(l1);
      read(r1);
      read(l2);
      read(r2);
      double sum1 = ITT.Get(l1, r1) / (r2 - l2 + 1),
             sum2 = ITT.Get(l2, r2) / (r2 - l2 + 1);
      ITT.Up(l1, r1,
             Data({sum2 / ((r1 - l1 + 1)), (double)(r1 - l1) / (r1 - l1 + 1)}));
      ITT.Up(l2, r2,
             Data({sum1 / ((r1 - l1 + 1)), (double)(r2 - l2) / (r2 - l2 + 1)}));
    } else {
      read(l1);
      read(r1);
      printf("%.6f\n", ITT.Get(l1, r1));
    }
  }
}
