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;
template <typename T, typename U>
ostream& operator<<(ostream& os, const pair<T, U>& p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}
template <typename T>
ostream& operator<<(ostream& os, const vector<T>& v) {
  os << "[";
  for (__typeof((v).begin()) i = (v).begin(); i != (v).end(); ++i) {
    if (i != v.begin()) os << ", ";
    os << *i;
  }
  os << "]";
  return os;
}
struct Interval {
  int u, v;
  double p;
  Interval(int _u, int _v, double _p) : u(_u), v(_v), p(_p) {}
};
bool operator<(const Interval& a, const Interval& b) {
  if (a.u != b.u) return a.u < b.u;
  return a.v > b.v;
}
ostream& operator<<(ostream& os, const Interval& a) {
  os << "(" << a.u << "," << a.v << "," << a.p << ")";
  return os;
}
int n, q;
vector<int> A;
vector<Interval> E;
pair<int, vector<double> > solve(int a, int b) {
  if (a == b) {
    int w = *max_element(A.begin() + E[a].u, A.begin() + E[a].v + 1);
    vector<double> P;
    P.push_back(1.0 - E[a].p);
    P.push_back(E[a].p);
    return pair<int, vector<double> >(w, P);
  }
  int w = -1023456789, f = E[a].u - 1;
  for (int i = (int)(a + 1); i <= (int)(b); ++i) {
    for (int k = (int)(f + 1); k <= (int)(E[i].u - 1); ++k) w = max(w, A[k]);
    f = max(f, E[i].v);
  }
  for (int k = (int)(f + 1); k <= (int)(E[a].v); ++k) w = max(w, A[k]);
  pair<int, vector<double> > res(w, vector<double>(1, 1.0));
  for (int i = a + 1; i <= b;) {
    int j = i;
    while (j + 1 <= b && E[j + 1].v <= E[i].v) ++j;
    pair<int, vector<double> > t = solve(i, j);
    vector<double> P;
    double sum_x = 0.0, sum_y = 0.0;
    for (int c = min(res.first, t.first);
         c < res.first + ((int)((res.second).size())) &&
         c < t.first + ((int)((t.second).size()));
         ++c) {
      if (c == max(res.first, t.first)) break;
      if (c - t.first < 0) {
        sum_x += res.second[c - res.first];
      } else {
        sum_y += t.second[c - t.first];
      }
    }
    for (int c = max(res.first, t.first);
         c < res.first + ((int)((res.second).size())) ||
         c < t.first + ((int)((t.second).size()));
         ++c) {
      if (c >= res.first + ((int)((res.second).size()))) {
        P.push_back(t.second[c - t.first]);
      } else if (c >= t.first + ((int)((t.second).size()))) {
        P.push_back(res.second[c - res.first]);
      } else {
        double x = res.second[c - res.first];
        double y = t.second[c - t.first];
        P.push_back(x * sum_y + y * sum_x + x * y);
        sum_x += x;
        sum_y += y;
      }
    }
    res = pair<int, vector<double> >(max(res.first, t.first), P);
    i = j + 1;
  }
  res.second.push_back(E[a].p * res.second.back());
  for (int i = (int)(((int)((res.second).size())) - 2); i >= (int)(1); --i)
    res.second[i] = (1.0 - E[a].p) * res.second[i] + E[a].p * res.second[i - 1];
  res.second[0] *= 1.0 - E[a].p;
  return res;
}
int main() {
  scanf("%d%d", &n, &q);
  A.resize(n + 2);
  A[0] = A[n + 1] = -1023456789;
  for (int i = (int)(1); i <= (int)(n); ++i) scanf("%d", &A[i]);
  E.push_back(Interval(0, n + 1, 0.0));
  for (int i = 0; i < (int)(q); ++i) {
    int u, v;
    double p;
    scanf("%d%d%lf", &u, &v, &p);
    E.push_back(Interval(u, v, p));
  }
  sort(E.begin(), E.end());
  pair<int, vector<double> > res = solve(0, ((int)((E).size())) - 1);
  double e = 0.0;
  for (int i = 0; i < (int)(((int)((res.second).size()))); ++i)
    e += res.second[i] * (res.first + i);
  printf("%.9lf\n", e);
}