#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
const ll mod = 1000000007;
const ll mxr = 1e6 + 10;
const ll oo = 3372036000000000;
int ar[501][501], val[501], n, m;
bool vis[501];
pair<int, int> cp(int lob, int hor, int i) {
  int tlb = lob, thr = hor;
  for (int r = 0; r < n; r++) {
    if (ar[i][r] != -1 && vis[r]) {
      tlb += val[r];
      thr += ar[i][r];
    }
  }
  return {tlb, thr};
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> n >> m;
  for (int i = 0; i < n; i++) cin >> val[i];
  memset(ar, -1, sizeof(ar));
  memset(vis, 0, sizeof(vis));
  ld mx = 0, ans;
  int ia = -1, ib = -1, lob = 0, hor = 0;
  for (int i = 0; i < m; i++) {
    int a, b, c, tv;
    cin >> a >> b >> c;
    a--, b--;
    tv = val[a] + val[b];
    ld tem = (ld)tv / c;
    ar[a][b] = c;
    ar[b][a] = c;
    if (tem > mx) {
      mx = tem;
      ia = a;
      ib = b;
      lob = tv, hor = c;
    }
  }
  if (ia == -1 && ib == -1) {
    cout << 0 << "\n";
    return 0;
  }
  vis[ia] = 1;
  vis[ib] = 1;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      if (!vis[j]) {
        pair<int, int> fr = cp(lob, hor, j);
        ld tem = (ld)fr.first / fr.second;
        if (tem > mx) {
          mx = tem;
          lob += fr.first;
          hor += fr.second;
          vis[j] = 1;
        }
      }
    }
  }
  cout << setprecision(12) << showpoint << fixed << mx << "\n";
  return 0;
}
