SP2899 VOL - Volunteers

Description

ACM ICPC World Finals 2009, sponsored by IBM and hosted by KTH, Royal Institute of Technology will be held in Stockholm, Sweden. This contest will last for _N_(1

Input Format

Ten test cases(given one after another, you have to process all!). For each test case: The first line contains two space-seperated integers _N_ and _M_. The second line contains N nonnegative integers _A $ _{i} $_ . _M_ lines follow, each contains three integers _S $ _{i} $_ , _T $ _{i} $_ and _C $ _{i} $_ . You may assume you can hire almost unlimited number of every type of volunteers. _Tip_: During your calculation, **int** in C/C++/Java or **longint** in Pascal is enough.

Output Format

For each test case: Output one line with an integer - the minimum cost.