//01分数问题 + SPFA问题
#include <bits/stdc++.h>
using namespace std;
const int N = 1010, M = 5010;
int h[N], e[M], ne[M], w[M], idx;
int f[N];
double dist[N];
int cnt[N];
bool st[N];
int l, p;
void add(int a, int b, int c)
{
e[idx] = b, w[idx] = c, ne[idx] = h[a], h[a] = idx ++;
}
//求正环
bool check(double mid)
{
queue<int> q;
memset(st, 0, sizeof st);
memset(dist, 0, sizeof dist);
memset(cnt, 0, sizeof cnt);
for (int i = 1; i <= l; i ++)
{
q.push(i);
st[i] = true;
}
while (q.size())
{
int t = q.front();
q.pop();
st[t] = false;
for (int i = h[t]; ~i; i = ne[i])
{
int j = e[i];
//求负环
//if (dist[j] > dist[t] + mid * w[i] - f[j])
if (dist[j] < dist[t] + f[j] - mid * w[i])
{
//求负环
//dist[j] = dist[t] + mid * w[i] - f[j];
dist[j] = dist[t] + f[j] - mid * w[i];
cnt[j] = cnt[t] + 1;
if (cnt[j] >= l) return true;
if (!st[j])
{
q.push(j);
st[j] = true;
}
}
}
}
return false;
}
int main(void)
{
memset(h, -1, sizeof h);
cin >> l >> p;
for (int i = 1; i <= l; i ++)
cin >> f[i];
for (int i = 0; i < p; i ++)
{
int a, b, c;
cin >> a >> b >> c;
add(a, b, c);
}
double l = 0, r = 1000;
while (r - l > 1e-4)
{
double mid = (r + l) / 2;
if (check(mid)) l = mid;
else r = mid;
}
printf("%.2lf\n", l);
return 0;
}