#include <bits/stdc++.h>
using namespace std;
long long mod = 1000000007;
double it[400009], add[400009], mul[400009], a[100009];
long long n, m;
void init(long long k, long long l, long long r) {
  mul[k] = 1;
  add[k] = 0;
  if (l == r) {
    it[k] = a[l];
    return;
  }
  long long mid = (l + r) / 2;
  init(k * 2, l, mid);
  init(k * 2 + 1, mid + 1, r);
  it[k] = it[k * 2] + it[k * 2 + 1];
}
void dolazy(long long k, long long l, long long r) {
  it[k] *= mul[k];
  it[k] += add[k] * (r - l + 1);
  if (l < r) {
    mul[k * 2] *= mul[k];
    mul[k * 2 + 1] *= mul[k];
    add[k * 2] = add[k * 2] * mul[k] + add[k];
    add[k * 2 + 1] = add[k * 2 + 1] * mul[k] + add[k];
  }
  mul[k] = 1;
  add[k] = 0;
}
void upd(long long k, long long l, long long r, long long L, long long R,
         double mu, double ad) {
  dolazy(k, l, r);
  if (r < L || r < l || R < l) return;
  long long mid = (l + r) / 2;
  if (L <= l && r <= R) {
    it[k] *= mu;
    it[k] += ad * (r - l + 1);
    if (l < r) {
      mul[k * 2] *= mu;
      mul[k * 2 + 1] *= mu;
      add[k * 2] = add[k * 2] * mu + ad;
      add[k * 2 + 1] = add[k * 2 + 1] * mu + ad;
    }
    return;
  }
  upd(k * 2, l, mid, L, R, mu, ad);
  upd(k * 2 + 1, mid + 1, r, L, R, mu, ad);
  it[k] = it[k * 2] + it[k * 2 + 1];
}
double getsum(long long k, long long l, long long r, long long L, long long R) {
  dolazy(k, l, r);
  if (r < L || r < l || R < l) return 0.0;
  if (L <= l && r <= R) return it[k];
  long long mid = (l + r) / 2;
  return getsum(k * 2, l, mid, L, R) + getsum(k * 2 + 1, mid + 1, r, L, R);
}
signed main() {
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(7);
  cin >> n >> m;
  for (long long i = 1; i <= n; i++) cin >> a[i];
  init(1, 1, n);
  while (m--) {
    long long t;
    cin >> t;
    if (t == 1) {
      long long l1, r1, l2, r2;
      cin >> l1 >> r1 >> l2 >> r2;
      double s1 = getsum(1, 1, n, l1, r1);
      double s2 = getsum(1, 1, n, l2, r2);
      double v1 = r1 - l1 + 1;
      double v2 = r2 - l2 + 1;
      upd(1, 1, n, l1, r1, (v1 - 1) / v1, s2 / v2 / v1);
      upd(1, 1, n, l2, r2, (v2 - 1) / v2, s1 / v1 / v2);
    } else {
      long long x, y;
      cin >> x >> y;
      cout << getsum(1, 1, n, x, y) << '\n';
    }
  }
}
