#include <bits/stdc++.h>
using namespace std;
ifstream fin("in.txt");
ofstream fout("out.txt");
int M[505][505], n, m, v, e, a, b, c, V[505], ax, bx;
double ans;
vector<int> ind;
bool visited[505];
int main() {
  cin >> n >> m;
  for (int i = 1; i < n + 1; i++) cin >> V[i];
  while (m--) {
    cin >> a >> b >> c;
    if ((v == 0 and e == 0) or (v * c < e * (V[a] + V[b]))) {
      visited[ax] = visited[bx] = 0;
      visited[a] = visited[b] = 1;
      ax = a, bx = b;
      v = V[a] + V[b];
      e = c;
    }
    M[a][b] = c;
    M[b][a] = c;
  }
  if (e)
    printf("%.10lf\n", (double)v / e);
  else
    printf("%.10lf\n", 0.0);
  return 0;
}
