Problem: Malek is a rich man. He also is very generous. That's why he decided to split his money between poor people. A charity institute knows n poor people numbered from 1 to n. The institute gave Malek q recommendations. A recommendation is a segment of people like [l, r] which means the institute recommended that Malek gives one dollar to every person whose number is in this segment.

However this charity has very odd rules about the recommendations. Because of those rules the recommendations are given in such a way that for every two recommendation [a, b] and [c, d] one of the following conditions holds: 

  * The two segments are completely disjoint. More formally either a ≤ b < c ≤ d or c ≤ d < a ≤ b
  * One of the two segments are inside another. More formally either a ≤ c ≤ d ≤ b or c ≤ a ≤ b ≤ d. 



The goodness of a charity is the value of maximum money a person has after Malek finishes giving his money. The institute knows for each recommendation what is the probability that Malek will accept it. They want to know the expected value of goodness of this charity. So they asked you for help.

You have been given the list of recommendations and for each recommendation the probability of it being accepted by Malek. You have also been given how much money each person initially has. You must find the expected value of goodness.

Input

In the first line two space-separated integers n, q (1 ≤ n ≤ 105, 1 ≤ q ≤ 5000) are given.

In the second line n space-separated integers a1, a2, ..., an (0 ≤ ai ≤ 109) are given meaning that person number i initially has ai dollars. 

Each of the next q lines contains three space-separated numbers li, ri, pi (1 ≤ li ≤ ri ≤ n, 0 ≤ p ≤ 1) where li and ri are two integers describing the segment of recommendation and pi is a real number given with exactly three digits after decimal point which is equal to probability of Malek accepting this recommendation.

Note that a segment may appear several times in recommendations.

Output

Output the sought value. Your answer will be considered correct if its absolute or relative error is less than 10 - 6.

Examples

Input

5 2
1 7 2 4 3
1 3 0.500
2 2 0.500


Output

8.000000000


Input

5 2
281 280 279 278 282
1 4 1.000
1 4 0.000


Output

282.000000000


Input

3 5
1 2 3
1 3 0.500
2 2 0.250
1 2 0.800
1 1 0.120
2 2 0.900


Output

4.465000000

Solution (in CPP):

Solution:
#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:256000000")
using namespace std;
const long double PI = 3.14159265358979323846;
const long double gammama = 0.57721566490153286060;
const long double eps = 1e-5;
const int INF = 1000 * 1000 * 1000 + 1;
const long long LINF = (long long)1000 * 1000 * 1000 * 1000 * 1000 * 1000;
const long long mod = 1000 * 1000 * 1000 + 7;
const long long N = 1001;
struct SegTree {
  int n, N;
  vector<int> a;
  int build(int v, int l, int r, const vector<int>& b) {
    if (l == r) {
      a[v] = b[l];
      return a[v];
    }
    int m = (l + r) / 2;
    a[v] = max(build(2 * v, l, m, b), build(2 * v + 1, m + 1, r, b));
    return a[v];
  }
  SegTree(const vector<int>& b) {
    n = b.size();
    N = 4 * n + 10;
    a.assign(N, 0);
    build(1, 0, n - 1, b);
  }
  int get(int v, int tl, int tr, int l, int r) {
    if ((tr < l) || (tl > r)) return 0;
    if ((tl >= l) && (tr <= r)) return a[v];
    int tm = (tl + tr) / 2;
    return max(get(2 * v, tl, tm, l, r), get(2 * v + 1, tm + 1, tr, l, r));
  }
  int get(int l, int r) { return get(1, 0, n - 1, l, r); }
};
struct vertex {
  int l, r;
  double p;
  int a;
};
vector<vector<int> > g;
vector<int> pr;
vector<vertex> b;
vector<vector<double> > res;
bool operator<(const vertex& a, const vertex& b) {
  return (a.l < b.l) || ((a.l == b.l) && (a.r > b.r));
}
double get(const vector<double> a) {
  double ans = 1;
  for (int i = 0; i < a.size(); ++i) ans *= 1 - a[i];
  return 1 - ans;
}
double getRes(int pos, int add) {
  if (add <= 0) return 1.0;
  if (add >= res[pos].size()) return 0;
  if (res[pos][add] > -0.5) return res[pos][add];
  double res1 = 1, res0 = 1;
  int need1 = b[pos].a + add - 1, need0 = b[pos].a + add;
  for (int i = 0; i < g[pos].size(); ++i) {
    int to = g[pos][i];
    res1 *= 1 - getRes(to, need1 - b[to].a);
    res0 *= 1 - getRes(to, need0 - b[to].a);
  }
  res1 = 1 - res1;
  res0 = 1 - res0;
  double ans = b[pos].p * res1 + (1 - b[pos].p) * res0;
  if (add == 1) ans = b[pos].p + (1 - b[pos].p) * res0;
  res[pos][add] = ans;
  return ans;
}
void solve() {
  int n, q;
  cin >> n >> q;
  vector<int> a(n);
  for (int i = 0; i < n; ++i) cin >> a[i];
  SegTree tr(a);
  b.resize(q + 1);
  for (int i = 0; i < q; ++i) {
    cin >> b[i].l >> b[i].r >> b[i].p;
    --b[i].l, --b[i].r;
  }
  b[q].l = 0, b[q].r = n - 1, b[q].p = 0;
  sort(b.begin(), b.end());
  g.resize(q + 1);
  pr.assign(q + 1, -1);
  int cur = 0;
  for (int i = 0; i < b.size(); ++i) {
    b[i].a = tr.get(b[i].l, b[i].r);
    if (i == 0) continue;
    while (!((b[i].l >= b[cur].l) && (b[i].r <= b[cur].r))) cur = pr[cur];
    g[cur].push_back(i);
    pr[i] = cur;
    cur = i;
  }
  res.assign(q + 1, vector<double>(q + 1, -1));
  double ans = b[0].a;
  for (int i = 1; i < q + 1; ++i) {
    ans += getRes(0, i);
  }
  printf("%0.12f\n", ans);
}
int main() {
  ios_base::sync_with_stdio(0);
  solve();
  return 0;
}