#include <bits/stdc++.h>
const int N = 100010;
struct node {
  int l, r;
  double sum, add, mul;
} a[N << 2];
int n, q;
int read() {
  int d = 0, f = 1;
  char c = getchar();
  while (c < '0' || c > '9') {
    if (c == '-') f = -1;
    c = getchar();
  }
  while (c >= '0' && c <= '9') d = d * 10 + c - 48, c = getchar();
  return d * f;
}
void pushup(int i) { a[i].sum = a[i << 1].sum + a[i << 1 | 1].sum; }
void pushdown(int i) {
  int i1 = i << 1, i2 = i1 | 1;
  a[i1].sum = a[i1].sum * a[i].mul + a[i].add * (a[i1].r - a[i1].l + 1);
  a[i1].mul *= a[i].mul;
  a[i1].add = a[i1].add * a[i].mul + a[i].add;
  a[i2].sum = a[i2].sum * a[i].mul + a[i].add * (a[i2].r - a[i2].l + 1);
  a[i2].mul *= a[i].mul;
  a[i2].add = a[i2].add * a[i].mul + a[i].add;
  a[i].add = 0;
  a[i].mul = 1;
}
void build(int i, int l, int r) {
  a[i].l = l;
  a[i].r = r;
  a[i].mul = 1;
  if (l == r) {
    a[i].sum = read();
    return;
  }
  int mid = (l + r) >> 1;
  build(i << 1, l, mid);
  build(i << 1 | 1, mid + 1, r);
  pushup(i);
}
double query(int i, int l, int r) {
  if (l <= a[i].l && a[i].r <= r) return a[i].sum;
  pushdown(i);
  int mid = (a[i].l + a[i].r) >> 1;
  if (r <= mid)
    return query(i << 1, l, r);
  else if (l > mid)
    return query(i << 1 | 1, l, r);
  else
    return query(i << 1, l, mid) + query(i << 1 | 1, mid + 1, r);
}
void Mul(int i, int l, int r, double x) {
  if (l <= a[i].l && a[i].r <= r) {
    a[i].sum *= x;
    a[i].add *= x;
    a[i].mul *= x;
    return;
  }
  pushdown(i);
  int mid = (a[i].l + a[i].r) >> 1;
  if (r <= mid)
    Mul(i << 1, l, r, x);
  else if (l > mid)
    Mul(i << 1 | 1, l, r, x);
  else
    Mul(i << 1, l, mid, x), Mul(i << 1 | 1, mid + 1, r, x);
  pushup(i);
}
void Add(int i, int l, int r, double x) {
  if (l <= a[i].l && a[i].r <= r) {
    a[i].sum += x * (a[i].r - a[i].l + 1);
    a[i].add += x;
    return;
  }
  pushdown(i);
  int mid = (a[i].l + a[i].r) >> 1;
  if (r <= mid)
    Add(i << 1, l, r, x);
  else if (l > mid)
    Add(i << 1 | 1, l, r, x);
  else
    Add(i << 1, l, mid, x), Add(i << 1 | 1, mid + 1, r, x);
  pushup(i);
}
int main() {
  n = read();
  q = read();
  build(1, 1, n);
  while (q--) {
    int op = read(), l = read(), r = read();
    if (op == 1) {
      int L = read(), R = read(), len1 = r - l + 1, len2 = R - L + 1;
      double sum1 = query(1, l, r), sum2 = query(1, L, R);
      Mul(1, l, r, (len1 - 1) * 1.0 / len1);
      Mul(1, L, R, (len2 - 1) * 1.0 / len2);
      Add(1, l, r, 1.0 / len1 * sum2 / len2);
      Add(1, L, R, 1.0 / len2 * sum1 / len1);
    } else
      printf("%.6lf\n", query(1, l, r));
  }
  return 0;
}
