#include <bits/stdc++.h>
using namespace std;
pair<int, pair<int, int> > w[505 * 505];
int a[505];
int main() {
  int x, n, i, m, u, v, c;
  double nodes, edges, ans, max1;
  scanf("%d %d", &n, &m);
  max1 = 0.0;
  for (i = 1; i <= n; i++) {
    scanf("%d", &x);
    a[i] = x;
  }
  for (i = 1; i <= m; i++) {
    scanf("%d %d %d", &u, &v, &c);
    w[i].first = c;
    w[i].second.first = u;
    w[i].second.second = v;
    nodes = double(a[w[i].second.first] + a[w[i].second.second]);
    edges = double(w[i].first);
    ans = nodes / edges;
    if (ans > max1) max1 = ans;
  }
  if (m == 0) max1 = 0.0;
  printf("%.12lf\n", max1);
  return 0;
}
