#include <bits/stdc++.h>
using namespace std;
int n, m;
int G[512][512], x[512];
bool ok(long double k) {
  for (int i = 0; i < n; i++) {
    for (int j = i + 1; j < n; j++) {
      if (G[i][j] and 1. * (x[i] + x[j]) / G[i][j] > k) return 1;
    }
  }
  return 0;
}
long double solve() {
  long double lb = 0., ub = 10000000., mid;
  for (int _ = 0; _ < 100; _++) {
    mid = (lb + ub) / 2;
    if (ok(mid))
      lb = mid;
    else
      ub = mid;
  }
  return lb;
}
void input() {
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    cin >> x[i];
  }
  for (int j = 0; j < m; j++) {
    int a, b, c;
    cin >> a >> b >> c;
    a--;
    b--;
    G[a][b] = G[b][a] = c;
  }
}
int main() {
  cin.tie(0);
  cin.sync_with_stdio(0);
  cout << fixed << setprecision(12);
  input();
  cout << solve() << endl;
  return 0;
}
