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 JAVA):

Solution:
import java.util.List;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.ArrayList;
import java.io.BufferedReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.util.Collection;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		FastScanner in = new FastScanner(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskC solver = new TaskC();
		solver.solve(1, in, out);
		out.close();
	}
}

class TaskC {
    public void solve(int testNumber, FastScanner in, PrintWriter out) {
		int n = in.nextInt();
		q = in.nextInt();
		tree = new MaxTree(n);
		for (int i = 0; i < n; i++) {
			int x = in.nextInt();
			tree.update(i, x);
		}
		++q;
		Segment[] s = new Segment[q];
		for (int i = 0; i < q - 1; i++) {
			int l = in.nextInt() - 1;
			int r = in.nextInt() - 1;
			double p = in.nextDouble();
			s[i] = new Segment(l, r, p);
		}
		s[q - 1] = new Segment(0, n - 1, 0.0);
		Arrays.sort(s);
		Segment[] stack = new Segment[q];
		int ptr = 0;
		stack[ptr++] = s[0];
		for (int i = 1; i < s.length; i++) {
			while (!stack[ptr - 1].contains(s[i])) {
				--ptr;
			}
			s[i].parent = stack[ptr - 1];
			stack[ptr - 1].children.add(s[i]);
			stack[ptr++] = s[i];
		}
		for (int i = 0; i < s.length; i++) {
			if (s[i].children.isEmpty()) {
				continue;
			}
			List<Segment> ch = s[i].children;
			List<Segment> fake = new ArrayList<Segment>();
			if (s[i].l != ch.get(0).l) {
				fake.add(new Segment(s[i].l, ch.get(0).l - 1, 0.0));
			}
			int sz = ch.size();
			if (s[i].r != ch.get(sz - 1).r) {
				fake.add(new Segment(ch.get(sz - 1).r + 1, s[i].r, 0.0));
			}
			for (int j = 0; j + 1 < sz; j++) {
				int r = ch.get(j).r;
				int l = ch.get(j + 1).l;
				if (r != l) {
					fake.add(new Segment(r + 1, l - 1, 0.0));
				}
			}
			ch.addAll(fake);
		}
		Segment root = s[0];
		solve(root);
		double ans = root.max;
		double[] p = root.prob;
		for (int i = 1; i <= q; i++) {
			ans += i * (p[i] - p[i - 1]);
		}
		out.printf("%.9f\n", ans);
    }

	int q;
	MaxTree tree;

	private void solve(Segment s) {
		s.prob = new double[q + 1];
		s.max = tree.getMax(s.l, s.r);
		if (s.children.isEmpty()) {
			Arrays.fill(s.prob, 1.0);
			s.prob[0] = 1 - s.p;
			return;
		}
		final int version = 3; // all three should be correct
		if (version == 1) {
			for (Segment ch : s.children) {
				solve(ch);
			}
			for (int i = 0; i <= q; i++) {
				double hit = 0;
				double notYet = 1;
				for (Segment ch : s.children) {
					int j = s.max + i - ch.max;
					if (j <= q) {
						double pLess = (j == 0 ? 0 : ch.prob[j - 1]);
						double pEq = ch.prob[j] - pLess;
						double nHit = hit * (pLess + pEq) + notYet * pEq;
						double nNotYet = notYet * pLess;
						hit = nHit;
						notYet = nNotYet;
					}
				}
				// exactly s.max+i
				s.prob[i] += hit * (1 - s.p);
				if (i < q) {
					s.prob[i + 1] += hit * s.p;
				}
			}
			// from "=" to "<="
			for (int i = 1; i <= q; i++) {
				s.prob[i] += s.prob[i - 1];
			}
		}
		if (version == 2) {
			for (Segment ch : s.children) {
				solve(ch);
			}
			for (int i = 0; i <= q; i++) {
				double prod1 = 1.0;
				double prod2 = 1.0;
				for (Segment ch : s.children) {
					int j = s.max + i - ch.max;
					if (j <= q) {
						prod1 *= ch.prob[j];
					}
					if (j == 0) {
						prod2 = 0;
					} else if (j - 1 <= q) {
						prod2 *= ch.prob[j - 1];
					}
				}
				// all <= j, but not all <= j - 1
				s.prob[i] += (1 - s.p) * (prod1 - prod2);
				if (i + 1 <= q) {
					s.prob[i + 1] += s.p * (prod1 - prod2);
				}
			}
			// from "=" to "<="
			for (int i = 1; i <= q; i++) {
				s.prob[i] += s.prob[i - 1];
			}
		}
		if (version == 3) {
			for (Segment ch : s.children) {
				solve(ch);
			}
			for (int i = 0; i <= q; i++) {
				double prod1 = 1.0;
				double prod2 = 1.0;
				for (Segment ch : s.children) {
					int j = s.max + i - ch.max;
					if (j <= q) {
						prod1 *= ch.prob[j];
					}
					if (j == 0) {
						prod2 = 0;
					} else if (j - 1 <= q) {
						prod2 *= ch.prob[j - 1];
					}
				}
				// unlike versions 1 and 2, here we calculate for "<=" directly
				s.prob[i] += (1 - s.p) * prod1;
				s.prob[i] += s.p * prod2;
			}
		}
	}

	class Segment implements Comparable<Segment> {
		int l, r;
		double p;
		Segment parent;
		List<Segment> children = new ArrayList<Segment>();
		double[] prob; // prob[i] = probability to achieve s.max+i or less for this segment

		int max;

		Segment(int l, int r, double p) {
			this.l = l;
			this.r = r;
			this.p = p;
		}
		public boolean contains(Segment o) {
			return l <= o.l && r >= o.r;
		}
		public int compareTo(Segment o) {
			if (l != o.l) {
				return l < o.l ? -1 : 1;
			}
			if (r != o.r) {
				return r > o.r ? -1 : 1;
			}
			return 0;
		}

	}

	class MaxTree {
		int[] a;
		int n;
		MaxTree(int n) {
			this.n = n;
			int k = 1;
			while (k < n) {
				k *= 2;
			}
			a = new int[2 * k];
		}
		void update(int i, int val) {
			i += n;
			while (true) {
				a[i] = Math.max(a[i], val);
				if (i == 0) {
					break;
				}
				i = (i - 1) / 2;
			}
		}
		int getMax(int l, int r) {
			if (l > r) {
				return 0;
			}
			l += n;
			r += n;
			if (l == r) {
				return a[l];
			}
			int lm = a[l];
			int rm = a[r];
			while (r - l > 1) {
				if (l % 2 == 1) {
					lm = Math.max(lm, a[l + 1]);
				}
				if (r % 2 == 0) {
					rm = Math.max(rm, a[r - 1]);
				}
				l = (l - 1) / 2;
				r = (r - 1) / 2;
			}
			return Math.max(lm, rm);
		}
	}
}

class FastScanner {

	private BufferedReader in;
	private StringTokenizer st;

	public FastScanner(InputStream stream) {
		in = new BufferedReader(new InputStreamReader(stream));
	}

	public String next() {
		while (st == null || !st.hasMoreTokens()) {
			try {
				st = new StringTokenizer(in.readLine());
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		return st.nextToken();
	}

	public int nextInt() {
		return Integer.parseInt(next());
	}

	public long nextLong() {
		return Long.parseLong(next());
	}

	public double nextDouble() {
		return Double.parseDouble(next());
	}

}