#include <bits/stdc++.h>   using namespace std;   inline int read() {     int x = 0, f = 1, c = getchar();     while (c < 48) c ==  -  && (f = -1), c = getchar();     while (c > 47) x = x * 10 + c -  0 , c = getchar();     return x * f;   }   const int MAXN = 100005;   struct Node {     int l, r, mx;     double p;   } q[5005];   std::vector<int> G[5005];   int lg[MAXN], fac[20], st[18][MAXN];   double f[5005][5005];   int n, m;   bool operator<(Node a, Node b) { return a.l ^ b.l ? a.l < b.l : a.r > b.r; }   inline void dfs(int x) {     double p = 1;     for (int y : G[x]) dfs(y);     for (int y : G[x]) p *= f[y][q[x].mx - q[y].mx];     f[x][0] = (1 - q[x].p) * p;     for (int i = 1; i <= m; ++i) {       double lp = 1, rp = 1;       for (int y : G[x]) {         lp *= f[y][min(q[x].mx + i - q[y].mx - 1, m)];         rp *= f[y][min(q[x].mx + i - q[y].mx, m)];       }       f[x][i] = q[x].p * lp + (1 - q[x].p) * rp;     }   }   inline int query(int l, int r) {     int k = lg[r - l + 1];     return max(st[k][l], st[k][r - fac[k] + 1]);   }   inline void buildst() {     for (int i = 1; i <= n; ++i) st[0][i] = read();     for (int i = fac[0] = 1; i < 20; ++i) fac[i] = fac[i - 1] << 1;     for (int i = 2; i <= n; ++i) lg[i] = lg[i >> 1] + 1;     for (int j = 1; j < 17; ++j)       for (int i = 1; i + fac[j] - 1 <= n; ++i)         st[j][i] = max(st[j - 1][i], st[j - 1][i + fac[j - 1]]);   }   int main(int argc, char const *argv[]) {     n = read();     m = read();     buildst();     for (int i = 1; i <= m; ++i) {       q[i].l = read();       q[i].r = read();       scanf( %lf , &q[i].p);       q[i].mx = query(q[i].l, q[i].r);     }     q[++m] = Node{1, n, query(1, n), 0};     sort(q + 1, q + m + 1);     for (int i = 2; i <= m; ++i)       for (int j = i - 1; j; --j)         if (q[j].l <= q[i].l && q[i].r <= q[j].r) {           G[j].push_back(i);           break;         }     dfs(1);     double ans = f[1][0] * q[1].mx;     for (int i = 1; i <= m; ++i) ans += (f[1][i] - f[1][i - 1]) * (q[1].mx + i);     printf( %lf n , ans);     return 0;   }   