#include <bits/stdc++.h>
using namespace std;
const int maxn = 510;
int n, m, weight[maxn];
int main() {
  while (scanf("%d%d", &n, &m) != EOF) {
    int i, j, u, v, w, x, y;
    int cntx = -1, cnty = -1;
    double s = 0;
    for (i = 1; i <= n; i++) {
      scanf("%d", &weight[i]);
    }
    if (m == 0) {
      printf("%0.10lf\n", s);
      continue;
    }
    for (i = 0; i < m; i++) {
      scanf("%d%d%d", &u, &v, &w);
      if (i == 0) {
        cntx = weight[u] + weight[v];
        cnty = w;
        continue;
      }
      x = weight[u] + weight[v];
      y = w;
      if (x * cnty > y * cntx) {
        cntx = x;
        cnty = y;
      }
    }
    s = double(cntx) / (double)(cnty);
    printf("%0.10lf\n", s);
  }
  return 0;
}
