#include <cstdio>

#include <cstdlib>

#include <iostream>

#include <vector>

#include <algorithm>

#include <queue>

using namespace std ;

int L,P ;

int fun [ 1001 ] ;

double maxfun = 0.0 ;

vector < pair < int , int > > graph [ 1001 ] ; //first=to,second=uzunluk

inline bool comp ( pair < pair < int ,vector < bool > > ,pair < int , int > > & a, pair < pair < int ,vector < bool > > ,pair < int , int > > & b ) {

return ( double ) a. second . first / ( double ) a. second . second > ( double ) b. second . first / ( double ) b. second . second ? true : false ;

}

void dfs ( int s ) {

vector < pair < int , int > > fundegree ( L,make_pair ( 0 , 1 ) ) ; //ilki total fun,ikinci time

priority_queue < pair < pair < int ,vector < bool > > ,pair < int , int > > , vector < pair < pair < int ,vector < bool > > ,pair < int , int > > > , comp > mypq ;

vector < bool > visited ( L, false ) ;

visited [ s ] = true ;

mypq. push ( make_pair ( make_pair ( s,visited ) ,make_pair ( fun [ s ] , 0 ) ) ) ;

pair < pair < int ,vector < bool > > ,pair < int , int > > temp ;

while ( ! mypq. empty ( ) ) {

temp = mypq. top ( ) ; mypq. pop ( ) ;

for ( int i = 0 ; i < graph [ temp. first . second ] . size ( ) ; i ++ ) {

if ( ( double ) fundegree [ graph [ temp. first . first ] [ i ] . first ] . first / ( double ) fundegree [ graph [ temp. first . first ] [ i ] . first ] . second < ( double ) ( temp. second . first + ( temp. first . second [ graph [ temp. first . first ] [ i ] . first ] == false ? fun [ graph [ temp. first . first ] [ i ] . first ] : 0 ) ) / ( double ) ( temp. second . second + graph [ temp. first . first ] [ i ] . second ) ) {

temp. second . first = fundegree [ graph [ temp. first . first ] [ i ] . first ] . first = ( temp. second . first + ( temp. first . second [ graph [ temp. first . first ] [ i ] . first ] == false ? fun [ graph [ temp. first . first ] [ i ] . first ] : 0 ) ) ;

temp. second . second = fundegree [ graph [ temp. first . first ] [ i ] . first ] . second = ( temp. second . second + graph [ temp. first . first ] [ i ] . second ) ;

temp. first . second [ graph [ temp. first . first ] [ i ] . first ] = true ;

temp. first . first = graph [ temp. first . first ] [ i ] . first ;

mypq. push ( temp ) ;

}

}

}

maxfun = max ( maxfun, ( double ) fundegree [ s ] . first / ( double ) fundegree [ s ] . second ) ;

/*for(int i=0;i<L;i++){

cout << i+1 << " " << fundegree[i].first << " " << fundegree[i].second << endl;

}*/

}

int main ( ) {

freopen ( "sightsee.in" , "r" , stdin ) ;

freopen ( "sightsee.out" , "w" , stdout ) ;

cin >> L >> P ;

for ( int i = 0 ; i < L ; i ++ )

cin >> fun [ i ] ;

for ( int i = 0 ; i < P ; i ++ ) {

int a,b,c ;

cin >> a >> b >> c ;

a -- ; b -- ;

graph [ a ] . push_back ( make_pair ( b,c ) ) ;

}

for ( int i = 0 ; i < L ; i ++ )

dfs ( i ) ;

printf ( "%.2lf

" ,maxfun ) ;

fclose ( stdin ) ;

fclose ( stdout ) ;