#include <bits/stdc++.h>
using namespace std;
template <class T>
T sqr(const T &a) {
  return a * a;
}
int n, m, w[500], x, y, z, used[500], pos;
vector<pair<int, int> > a[500];
double ans;
pair<double, double> t, d[500];
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 0; i < (int)n; i++) scanf("%d", &w[i]);
  for (int i = 0; i < (int)m; i++) {
    scanf("%d%d%d", &x, &y, &z);
    x--, y--;
    a[x].push_back(make_pair(y, z));
    a[y].push_back(make_pair(x, z));
  }
  for (int q = 0; q < (int)n; q++) {
    for (int i = 0; i < (int)n; i++) {
      used[i] = 0;
      d[i] = make_pair(w[i], 0);
    }
    for (int i = 0; i < (int)a[q].size(); i++)
      d[a[q][i].first].second += a[q][i].second;
    used[q] = 1;
    t = make_pair(w[q], 0);
    for (int j = 0; j < (int)n; j++) {
      pos = -1;
      for (int i = 0; i < (int)n; i++)
        if (!used[i] && d[i].second != 0)
          if ((t.second == 0 ||
               (t.first + d[i].first) / (t.second + d[i].second) >
                   t.first / t.second) &&
              (pos == -1 ||
               (t.first + d[i].first) / (t.second + d[i].second) >
                   (t.first + d[pos].first) / (t.second + d[pos].second)))
            pos = i;
      if (pos == -1) break;
      t.first += d[pos].first, t.second += d[pos].second;
      used[pos] = 1;
      for (int i = 0; i < (int)a[pos].size(); i++)
        if (!used[a[pos][i].first])
          d[a[pos][i].first].second += a[pos][i].second;
    }
    if (t.second != 0) ans = max(ans, t.first / t.second);
  }
  printf("%.10lf\n", ans);
}
