#include <bits/stdc++.h>
using namespace std;
const int inf = (int)1e9, maxn = (int)1e5 + 1;
const double eps = (double)1e-8;
const int mod = (int)1000000009;
vector<int> b[501];
int n, m, z[501], x, y, c, a[501][501], e, v, u, nv, ne, me, mv, ee, vv;
bool f[501], t;
double mx, o, oo = double(-1);
int main() {
  cout << fixed << setprecision(15);
  cin >> n >> m;
  for (int i = 1; i <= n; i++) {
    cin >> z[i];
    vv += z[i];
  }
  memset(a, -1, sizeof a);
  for (int i = 1; i <= m; i++) {
    scanf("%d", &(x));
    scanf("%d", &(y));
    scanf("%d", &(c));
    a[x][y] = c;
    a[y][x] = c;
    b[x].push_back(y);
    b[y].push_back(x);
    ee += c;
  }
  oo = -1;
  for (int x = 1; x <= n; x++) {
    memset(f, 0, sizeof f);
    f[x] = 1;
    e = 0;
    v = z[x];
    while (1) {
      u = -1;
      if (e == 0)
        mx = 0;
      else
        mx = double(v) / e;
      for (int i = 1; i <= n; i++)
        if (!f[i]) {
          t = 0;
          nv = v + z[i];
          ne = e;
          for (int j = 0; j < b[i].size(); j++)
            if (f[b[i][j]]) {
              t = 1;
              ne += a[i][b[i][j]];
            }
          if (t && double(nv) / ne > mx) {
            mx = double(nv) / ne;
            me = ne;
            mv = nv;
            u = i;
          }
        }
      if (u == -1) {
        o = mx;
        break;
      } else {
        e = me;
        v = mv;
        f[u] = 1;
      }
    }
    oo = max(o, oo);
  }
  cout << oo;
  return 0;
}
