#include <bits/stdc++.h>
using namespace std;
const double pi = acos(-1.0);
const double eps = 1e-8;
const int INF = 1E9;
const int MAXN = 100500;
int n, m, u, v, c;
int a[MAXN];
double ans;
int main() {
  cin >> n >> m;
  for (int i = 0; i < (int)(n); i++) cin >> a[i];
  ans = 0;
  for (int i = 0; i < (int)(m); i++) {
    scanf("%d%d%d", &u, &v, &c);
    u--, v--;
    if (ans * c < a[u] + a[v]) ans = 1.0 * (a[u] + a[v]) / c;
  }
  cout.precision(30);
  cout << ans;
  return 0;
}
