#include <bits/stdc++.h>
using namespace std;
const int inf = 1LL << 30;
int g[512][512];
void solve(int ncase) {
  int n, m;
  cin >> n >> m;
  vector<int> vx(n);
  for (int i = 0; i < n; i++) {
    cin >> vx[i];
  }
  memset(g, -1, sizeof(g));
  for (int i = 0; i < m; i++) {
    int u, v, c;
    cin >> u >> v >> c;
    g[u - 1][v - 1] = g[v - 1][u - 1] = c;
  }
  double ans = 0;
  for (int i = 0; i < n; i++) {
    vector<int> mark(n, 0);
    mark[i] = 1;
    double cv = vx[i], ce = 0;
    double tmp = 0;
    int mj = -1;
    for (int j = 0; j < n; j++) {
      if (mark[j]) continue;
      if (g[i][j] == -1) continue;
      if ((cv + vx[j]) / (ce + g[i][j]) > tmp) {
        tmp = (cv + vx[j]) / (ce + g[i][j]);
        mj = j;
      }
    }
    if (mj == -1) continue;
    mark[mj] = 1;
    cv += vx[mj];
    ce += g[i][mj];
    while (1) {
      double tmp = cv / ce;
      ans = max(ans, tmp);
      int mj = -1;
      double ee = 0;
      for (int j = 0; j < n; j++) {
        if (mark[j]) continue;
        double e = 0;
        for (int k = 0; k < n; k++) {
          if (mark[k] && g[k][j] != -1) {
            e += g[k][j];
          }
        }
        if (e <= 0 + 1e-9) continue;
        if (tmp < (cv + vx[j]) / (ce + e)) {
          mj = j;
          ee = e;
        }
      }
      if (mj == -1) break;
      mark[mj] = 1;
      cv += vx[mj];
      ce += ee;
    }
  }
  cout << fixed << setprecision(16) << ans << endl;
}
int main() {
  ios::sync_with_stdio(false);
  int T = 1;
  int ncase = 0;
  while (T--) {
    solve(++ncase);
  }
}
