#include <bits/stdc++.h>
using namespace std;
const int inf = 2000000000;
static inline int Rint() {
  struct X {
    int dig[256];
    X() {
      for (int i = '0'; i <= '9'; ++i) dig[i] = 1;
      dig['-'] = 1;
    }
  };
  static X fuck;
  int s = 1, v = 0, c;
  for (; !fuck.dig[c = getchar()];)
    ;
  if (c == '-')
    s = 0;
  else if (fuck.dig[c])
    v = c ^ 48;
  for (; fuck.dig[c = getchar()]; v = v * 10 + (c ^ 48))
    ;
  return s ? v : -v;
}
template <typename T>
static inline void cmax(T& a, const T& b) {
  if (b > a) a = b;
}
template <typename T>
static inline void cmin(T& a, const T& b) {
  if (b < a) a = b;
}
const int maxn = 505;
int mat[maxn][maxn];
int mat1[maxn][maxn];
int w[maxn];
int visited[maxn];
int main() {
  const int n = Rint(), m = Rint();
  for (int i = 1; i <= n; ++i) w[i] = Rint();
  for (int i = (0); i < (m); ++i) {
    int s = Rint(), t = Rint(), c = Rint();
    mat[s][t] = mat[t][s] = c;
  }
  double ans = 0;
  for (int start = 1; start <= n; ++start) {
    long long totalw = w[start];
    long long totale = 0;
    fill(visited, visited + n + 1, 0);
    visited[start] = 1;
    memcpy(mat1, mat, sizeof mat);
    for (int x = 1; x < n; ++x) {
      long long id = -1, incw = 0, ince = 0;
      for (int j = 1; j <= n; ++j)
        if (visited[j] == 0 && mat1[start][j] > 0) {
          if (id == -1 || (totalw + w[j]) * (totale + ince) >
                              (totalw + incw) * (totale + mat1[start][j])) {
            id = j;
            incw = w[j];
            ince = mat1[start][j];
          }
        }
      if (id == -1) break;
      totalw += incw;
      totale += ince;
      double temp = 1.0 * totalw / totale;
      if (temp > ans) ans = temp;
      visited[id] = 1;
      for (int j = 1; j <= n; ++j)
        if (visited[j] == 0 && mat[id][j] > 0) {
          mat1[id][start] += mat[id][j];
          mat1[start][id] += mat[id][j];
        }
    }
  }
  printf("%.16f\n", ans);
  return 0;
}
