#include <bits/stdc++.h>
using namespace std;
const int N = 502;
const int M = N * (N - 1) / 2;
struct Edge {
  int v, w;
  Edge *nxt;
} edge[2 * M];
Edge *ecnt, *head[N];
int n, m, p[N];
bool vis[N];
double ans;
inline void AddEdge(int u, int v, int w) {
  ecnt->v = v;
  ecnt->w = w;
  ecnt->nxt = head[u];
  head[u] = ecnt++;
}
void Dfs(int u, int fa) {
  vis[u] = true;
  for (Edge *e = head[u]; e; e = e->nxt) {
    if (e->v == fa) continue;
    if (e->v == u)
      ans = max(ans, (double)p[u] / e->w);
    else
      ans = max(ans, ((double)p[u] + p[e->v]) / e->w);
    if (!vis[e->v]) Dfs(e->v, u);
  }
}
int main() {
  ecnt = &edge[0];
  scanf("%d %d", &n, &m);
  for (int i = 1; i <= n; i++) scanf("%d", &p[i]);
  for (int i = 1, u, v, w; i <= m; i++) {
    scanf("%d %d %d", &u, &v, &w);
    AddEdge(u, v, w);
    AddEdge(v, u, w);
  }
  for (int i = 1; i <= n; i++)
    if (!vis[i]) Dfs(i, i);
  printf("%.15lf\n", ans);
  return 0;
}
