#include <bits/stdc++.h>
int i, n, m, l, r, w, j, x;
double sum1, sum2, p, q, ans;
int d[520][520];
int vis[520], s[520], a[520];
int main() {
  scanf("%d%d", &n, &m);
  for (i = 1; i <= n; i++) scanf("%d", &a[i]);
  for (i = 1; i <= m; i++) {
    scanf("%d%d%d", &l, &r, &w);
    d[l][r] = w;
    d[r][l] = w;
  }
  for (i = 1; i <= n; i++) {
    memset(vis, 0, sizeof(vis));
    memset(s, 0, sizeof(s));
    sum1 = a[i];
    sum2 = 0;
    vis[i] = 1;
    for (j = 1; j <= n; j++)
      if ((d[i][j] > 0) && (vis[j] == 0)) s[j] += d[i][j];
    do {
      p = 0;
      x = 0;
      for (j = 1; j <= n; j++)
        if ((s[j]) && (vis[j] == 0)) {
          q = (sum1 + a[j]) / (sum2 + s[j]);
          if (q >= p) {
            p = q;
            x = j;
          }
        }
      if (x == 0)
        break;
      else {
        sum2 += s[x];
        sum1 += a[x];
        if (sum2 == 0)
          p = 0;
        else
          p = sum1 / sum2;
        if (p > ans) ans = p;
        vis[x] = 1;
        for (j = 1; j <= n; j++)
          if ((d[x][j] > 0) && (vis[x] == 0)) s[j] += d[x][j];
      }
    } while (true);
  }
  printf("%.15f", ans);
}
