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>
using namespace std;
double f[5005][5005], ans = 0;
vector<int> G[5005];
int n, q, a[200005], st[18][200005], mx[5005];
bool g[5005][5005];
struct ran {
  int l, r;
  double p;
} A[5005];
void prepare() {
  int i, j;
  for (i = 1; i < 18; i++)
    for (j = 1; j <= n; j++)
      st[i][j] = max(st[i - 1][j], st[i - 1][j + (1 << (i - 1))]);
}
int RMQ(int l, int r) {
  int t = (int)(log2(r - l + 1));
  return max(st[t][l], st[t][r - (1 << t) + 1]);
}
bool cmp(ran p, ran q) { return p.l < q.l || (p.l == q.l && p.r > q.r); }
void build(int ll, int rr) {
  int i, p = ll + 1;
  if (ll == rr) return;
  for (i = ll + 1; i <= rr + 1; i++)
    if (A[p].r < A[i].l || i > rr) {
      G[ll].push_back(p);
      build(p, i - 1), p = i;
    }
}
double dp(int t, int s) {
  int i;
  if (s < 0) return 0;
  double s1 = A[t].p, s2 = 1 - s1;
  if (s > q) return 1;
  if (g[t][s]) return f[t][s];
  for (i = 0; i < G[t].size(); i++) {
    s1 *= dp(G[t][i], mx[t] + s - mx[G[t][i]] - 1);
    s2 *= dp(G[t][i], mx[t] + s - mx[G[t][i]]);
  }
  if (s == 0) s1 = 0;
  f[t][s] = s1 + s2, g[t][s] = 1;
  return f[t][s];
}
int main() {
  int i;
  scanf("%d %d", &n, &q);
  memset(st, 128, sizeof(st));
  for (i = 1; i <= n; i++) scanf("%d", &a[i]), st[0][i] = a[i];
  prepare();
  for (i = 1; i <= q; i++) scanf("%d %d %lf", &A[i].l, &A[i].r, &A[i].p);
  sort(A + 1, A + q + 1, cmp);
  A[0] = (ran){1, n, 0};
  build(0, q);
  for (i = 0; i <= q; i++) mx[i] = RMQ(A[i].l, A[i].r);
  for (i = 0; i <= q; i++) ans += (dp(0, i) - dp(0, i - 1)) * (mx[0] + i);
  printf("%.9lf", ans);
  return 0;
}