#include <bits/stdc++.h>
using namespace std;
int n, m;
int val[508];
int graph[508][508];
int main() {
  while (~scanf("%d %d", &n, &m)) {
    for (int i = 1; i <= n; i++) {
      scanf("%d", &val[i]);
    }
    int u, v, w;
    for (int i = 1; i <= m; i++) {
      scanf("%d %d %d", &u, &v, &w);
      graph[u][v] = w;
      graph[v][u] = w;
    }
    double l = 0;
    double r = 5e8;
    double mid;
    while (fabs(r - l) > 1e-10) {
      bool flag = 1;
      mid = (l + r) / 2;
      for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= n; j++) {
          if (i == j) continue;
          if (graph[i][j] == 0) continue;
          if (mid * graph[i][j] - val[i] - val[j] < 0) {
            flag = 0;
            break;
          }
        }
        if (!flag) break;
      }
      if (flag)
        r = mid;
      else
        l = mid;
    }
    printf("%.9f\n", mid);
  }
  return 0;
}
