#include <bits/stdc++.h>
using namespace std;
int n, m;
double kq;
double valnode[510];
double valcanh[510][510];
int q[510], d[510], dd[510];
void xuly(int xp) {
  int i, j, k, dau, cuoi, u, nv, maxvt;
  double sume, sumv, tv, te, t, maxv, maxe;
  int v[510];
  nv = 0;
  dau = -1;
  cuoi = 0;
  q[0] = xp;
  d[xp] = 1;
  while (dau < cuoi) {
    dau++;
    u = q[dau];
    v[nv++] = u;
    for (i = 1; i <= n; i++)
      if (d[i] == 0 && valcanh[u][i] > 0.0) {
        cuoi++;
        q[cuoi] = i;
        d[i] = 1;
      }
  }
  sumv = 0.0;
  sume = 0.0;
  for (i = 0; i < nv; i++) sumv += valnode[v[i]];
  for (i = 0; i < nv; i++)
    for (j = i + 1; j < nv; j++) sume += valcanh[v[i]][v[j]];
  if (nv == 1) return;
  kq = max(kq, sumv / sume);
  for (i = 0; i < nv; i++) dd[i] = 0;
  for (i = 0; i < nv; i++)
    for (j = 0; j < nv; j++)
      if (i != j && valcanh[v[i]][v[j]] > 0.0) {
        kq = max(kq, (valnode[v[i]] + valnode[v[j]]) / (valcanh[v[i]][v[j]]));
      }
}
void solve() {
  int i;
  memset(d, 0, sizeof(d));
  kq = 0.0;
  for (i = 1; i <= n; i++)
    if (d[i] == 0) xuly(i);
  printf("%.15lf\n", kq);
}
void input() {
  int i, j, x, y;
  double val;
  scanf("%d %d", &n, &m);
  for (i = 1; i <= n; i++) scanf("%lf", &valnode[i]);
  for (i = 1; i <= n; i++)
    for (j = 1; j <= n; j++) valcanh[i][j] = 0.0;
  for (i = 0; i < m; i++) {
    scanf("%d %d %lf", &x, &y, &val);
    valcanh[x][y] = val;
    valcanh[y][x] = val;
  }
  solve();
}
int main() {
  input();
  fclose(stdin);
  fclose(stdout);
  return 0;
}
