#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<bitset>
#include<vector>
#include<deque>
#include<list>
#include<queue>
#include<map>
#include<set>
#include<stack>
#include<cmath>
#include<iomanip>
#include <functional>
using namespace std;
typedef long long ll;
const int mod = 1000000007;
const int INF = 1 << 28;
const double EPS = 1e-10;
//cout << fixed << std::setprecision(9)
//memset(a, 0, sizeof(a));
//--------------------------

int n, m;
ll X[100005];

//-----UnionFind--------
vector<int> par, rk, cn;

void initUnion(int n)
{
	for (int i = 0;i < n;i++) {
		par.push_back(i);
		rk.push_back(1);
		cn.push_back(0);
	}
}

int root(int x) {
	if (par[x] == x) return x;
	return par[x] = root(par[x]);
}

void unite(int x, int y) {
	int rx = root(x);
	int ry = root(y);
	if (rx == ry) return;

	if (rk[ry] < rk[rx]) swap(rx, ry);
	X[ry] += X[rx];
	rk[ry] += rk[rx];
	cn[ry] += cn[rx];
	par[rx] = ry;
}

bool same(int x, int y) {
	int rx = root(x);
	int ry = root(y);
	return rx == ry;
}
//-----UnionFind--------

class edge {
public:
	int u;
	int v;
	ll w;
};

bool comp(edge v, edge u)
{
	return v.w < u.w;
}

int main()
{
	cin >> n >> m;
	vector<edge> e(m);
	int u, v, w;

	for (int i = 0;i < n;i++) cin >> X[i];
	for (int i = 0;i < m;i++) {
		cin >> u >> v >> w;
		u--;
		v--;
		e[i].u = u;
		e[i].v = v;
		e[i].w = w;
	}

	sort(e.begin(), e.end(), comp);

	int ans = m;
	initUnion(n);

	for (int i = 0;i < m;i++) {
		w = e[i].w;
		v = e[i].v;
		u = e[i].u;

		if (!same(u, v)) {
			int Ru = root(u);
			int Rv = root(v);
			unite(u, v);
		}

		int Ru = root(u);
		cn[Ru]++;

		if (X[Ru] >= w) {
			ans -= cn[Ru];
			cn[Ru] = 0;
		}
	}

	cout << ans << endl;

	return 0;
}

### Prompt

Your task is to create a Cpp solution to the following problem:

There is a connected undirected graph with N vertices and M edges. The vertices are numbered 1 to N, and the edges are numbered 1 to M. Also, each of these vertices and edges has a specified weight. Vertex i has a weight of X_i; Edge i has a weight of Y_i and connects Vertex A_i and B_i.

We would like to remove zero or more edges so that the following condition is satisfied:

* For each edge that is not removed, the sum of the weights of the vertices in the connected component containing that edge, is greater than or equal to the weight of that edge.



Find the minimum number of edges that need to be removed.

Constraints

* 1 \leq N \leq 10^5
* N-1 \leq M \leq 10^5
* 1 \leq X_i \leq 10^9
* 1 \leq A_i < B_i \leq N
* 1 \leq Y_i \leq 10^9
* (A_i,B_i) \neq (A_j,B_j) (i \neq j)
* The given graph is connected.
* All values in input are integers.

Input

Input is given from Standard Input in the following format:


N M
X_1 X_2 ... X_N
A_1 B_1 Y_1
A_2 B_2 Y_2
:
A_M B_M Y_M


Output

Find the minimum number of edges that need to be removed.

Examples

Input

4 4
2 3 5 7
1 2 7
1 3 9
2 3 12
3 4 18


Output

2


Input

6 10
4 4 1 1 1 7
3 5 19
2 5 20
4 5 8
1 6 16
2 3 9
3 6 16
3 4 1
2 6 20
2 4 19
1 2 9


Output

4


Input

10 9
81 16 73 7 2 61 86 38 90 28
6 8 725
3 10 12
1 4 558
4 9 615
5 6 942
8 9 918
2 7 720
4 7 292
7 10 414


Output

8

### Response

```cpp
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<bitset>
#include<vector>
#include<deque>
#include<list>
#include<queue>
#include<map>
#include<set>
#include<stack>
#include<cmath>
#include<iomanip>
#include <functional>
using namespace std;
typedef long long ll;
const int mod = 1000000007;
const int INF = 1 << 28;
const double EPS = 1e-10;
//cout << fixed << std::setprecision(9)
//memset(a, 0, sizeof(a));
//--------------------------

int n, m;
ll X[100005];

//-----UnionFind--------
vector<int> par, rk, cn;

void initUnion(int n)
{
	for (int i = 0;i < n;i++) {
		par.push_back(i);
		rk.push_back(1);
		cn.push_back(0);
	}
}

int root(int x) {
	if (par[x] == x) return x;
	return par[x] = root(par[x]);
}

void unite(int x, int y) {
	int rx = root(x);
	int ry = root(y);
	if (rx == ry) return;

	if (rk[ry] < rk[rx]) swap(rx, ry);
	X[ry] += X[rx];
	rk[ry] += rk[rx];
	cn[ry] += cn[rx];
	par[rx] = ry;
}

bool same(int x, int y) {
	int rx = root(x);
	int ry = root(y);
	return rx == ry;
}
//-----UnionFind--------

class edge {
public:
	int u;
	int v;
	ll w;
};

bool comp(edge v, edge u)
{
	return v.w < u.w;
}

int main()
{
	cin >> n >> m;
	vector<edge> e(m);
	int u, v, w;

	for (int i = 0;i < n;i++) cin >> X[i];
	for (int i = 0;i < m;i++) {
		cin >> u >> v >> w;
		u--;
		v--;
		e[i].u = u;
		e[i].v = v;
		e[i].w = w;
	}

	sort(e.begin(), e.end(), comp);

	int ans = m;
	initUnion(n);

	for (int i = 0;i < m;i++) {
		w = e[i].w;
		v = e[i].v;
		u = e[i].u;

		if (!same(u, v)) {
			int Ru = root(u);
			int Rv = root(v);
			unite(u, v);
		}

		int Ru = root(u);
		cn[Ru]++;

		if (X[Ru] >= w) {
			ans -= cn[Ru];
			cn[Ru] = 0;
		}
	}

	cout << ans << endl;

	return 0;
}

```