#include <bits/stdc++.h>
using namespace std;
const int MAX = 1e3 + 10;
const int inf = 0x3f3f3f3f;
int H[MAX][MAX];
int vis[MAX][MAX];
double val[MAX];
int main() {
  int n, m;
  double E, V;
  while (scanf("%d %d", &n, &m) == 2) {
    E = V = 0;
    memset(H, 0, sizeof(H));
    memset(vis, 0, sizeof(vis));
    for (int i = 0; i < n; i++) {
      scanf("%lf", &val[i]);
      V += val[i];
    }
    int a, b, c;
    for (int i = 0; i < m; i++) {
      scanf("%d %d %d", &a, &b, &c);
      E += c;
      a--, b--;
      H[a][b] = H[b][a] = c;
      vis[a][b] = vis[b][a] = 1;
    }
    if (!E) {
      printf("%d\n", 0);
      return 0;
    }
    double ans = -inf;
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < n; j++)
        if (vis[i][j] && i != j) {
          if (H[i][j] != 0) {
            ans = max(ans, (val[i] + val[j]) / H[i][j]);
          }
        }
    }
    printf("%.15lf\n", ans);
  }
  return 0;
}
