#include <bits/stdc++.h>
using namespace std;
struct segment {
  int* p1;
  int* p2;
  int weight;
};
int main() {
  int n;
  int m;
  cin >> n >> m;
  int points[n];
  for (int i = 0; i < n; ++i) {
    scanf("%i", &points[i]);
  }
  segment seg[n];
  for (int i = 0; i < m; ++i) {
    int t1, t2, t3;
    scanf("%i%i%i", &t1, &t2, &t3);
    seg[i].p1 = &points[t1 - 1];
    seg[i].p2 = &points[t2 - 1];
    seg[i].weight = t3;
  }
  int toCut = 0;
  for (int i = 0; i < m; ++i) {
    if (seg[i].weight > *seg[i].p1 + *seg[i].p2) {
      ++toCut;
    }
  }
  cout << toCut;
}
