//qscqesze
#include <functional>
#include <algorithm>
#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <numeric>
#include <cstring>
#include <climits>
#include <cassert>
#include <complex>
#include <cstdio>
#include <string>
#include <vector>
#include <bitset>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <list>
#include <set>
#include <map>
using namespace std;
#define REP(i, n) for (int i=0;i<n;++i)
#define FOR(i, a, b) for (int i=a;i<b;++i)
#define DWN(i, b, a) for (int i=b-1;i>=a;--i)
#define REP_1(i, n) for (int i=1;i<=n;++i)
#define FOR_1(i, a, b) for (int i=a;i<=b;++i)
#define DWN_1(i, b, a) for (int i=b;i>=a;--i)
#define REP_C(i, n) for (int n____=n,i=0;i<n____;++i)
#define FOR_C(i, a, b) for (int b____=b,i=a;i<b____;++i)
#define DWN_C(i, b, a) for (int a____=a,i=b-1;i>=a____;--i)
#define REP_N(i, n) for (i=0;i<n;++i)
#define FOR_N(i, a, b) for (i=a;i<b;++i)
#define DWN_N(i, b, a) for (i=b-1;i>=a;--i)
#define REP_1_C(i, n) for (int n____=n,i=1;i<=n____;++i)
#define FOR_1_C(i, a, b) for (int b____=b,i=a;i<=b____;++i)
#define DWN_1_C(i, b, a) for (int a____=a,i=b;i>=a____;--i)
#define REP_1_N(i, n) for (i=1;i<=n;++i)
#define FOR_1_N(i, a, b) for (i=a;i<=b;++i)
#define DWN_1_N(i, b, a) for (i=b;i>=a;--i)
#define REP_C_N(i, n) for (int n____=(i=0,n);i<n____;++i)
#define FOR_C_N(i, a, b) for (int b____=(i=0,b);i<b____;++i)
#define DWN_C_N(i, b, a) for (int a____=(i=b-1,a);i>=a____;--i)
#define REP_1_C_N(i, n) for (int n____=(i=1,n);i<=n____;++i)
#define FOR_1_C_N(i, a, b) for (int b____=(i=a,b);i<=b____;++i)
#define DWN_1_C_N(i, b, a) for (int a____=(i=b,a);i>=a____;--i)
#define ECH(it, A) for (__typeof(A.begin()) it=A.begin(); it != A.end(); ++it)
#define REP_S(i, str) for (char*i=str;*i;++i)
#define REP_L(i, hd, suc) for (int i=hd;i;i=suc[i])
#define REP_G(i, u) REP_L(i,hd[u],suc)
#define REP_SS(x, s) for (int x=s;x;x=(x-1)&s)
#define DO(n) for ( int ____n = n; ____n-->0; )
#define REP_2(i, j, n, m) REP(i, n) REP(j, m)
#define REP_2_1(i, j, n, m) REP_1(i, n) REP_1(j, m)
#define REP_3(i, j, k, n, m, l) REP(i, n) REP(j, m) REP(k, l)
#define REP_3_1(i, j, k, n, m, l) REP_1(i, n) REP_1(j, m) REP_1(k, l)
#define REP_4(i, j, k, ii, n, m, l, nn) REP(i, n) REP(j, m) REP(k, l) REP(ii, nn)
#define REP_4_1(i, j, k, ii, n, m, l, nn) REP_1(i, n) REP_1(j, m) REP_1(k, l) REP_1(ii, nn)
#define ALL(A) A.begin(), A.end()
#define LLA(A) A.rbegin(), A.rend()
#define CPY(A, B) memcpy(A, B, sizeof(A))
#define INS(A, P, B) A.insert(A.begin() + P, B)
#define ERS(A, P) A.erase(A.begin() + P)
#define LBD(A, x) (lower_bound(ALL(A), x) - A.begin())
#define UBD(A, x) (upper_bound(ALL(A), x) - A.begin())
#define CTN(T, x) (T.find(x) != T.end())
#define SZ(A) int((A).size())
#define PB push_back
#define MP(A, B) make_pair(A, B)
#define PTT pair<T, T>
#define Ts *this
#define rTs return Ts
#define fi first
#define se second
#define re real()
#define im imag()
#define Rush for(int ____T=RD(); ____T--;)
#define Display(A, n, m) { \
REP(i, n){ \
REP(j, m-1) cout << A[i][j] << " "; \
cout << A[i][m-1] << endl; \
} \
}
#define Display_1(A, n, m) { \
REP_1(i, n){ \
REP_1(j, m-1) cout << A[i][j] << " "; \
cout << A[i][m] << endl; \
} \
}
typedef long long LL;
//typedef long double DB;
typedef double DB;
typedef unsigned uint;
typedef unsigned long long uLL;
typedef vector<int> VI;
typedef vector<char> VC;
typedef vector<string> VS;
typedef vector<LL> VL;
typedef vector<DB> VF;
typedef set<int> SI;
typedef set<string> SS;
typedef map<int, int> MII;
typedef map<string, int> MSI;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;
typedef vector<PII> VII;
typedef vector<VI> VVI;
typedef vector<VII> VVII;
//freopen("D.in","r",stdin);
//freopen("D.out","w",stdout);
#define RD(n) scanf("%d",&n)
#define RDD(n) scanf("%lf",&n)
#define RDLL(n) scanf("%lld",&n)
#define sspeed ios_base::sync_with_stdio(0);cin.tie(0)
#define maxn 100001
#define eps 1e-9
const int inf=0x7fffffff;
#define pi 3.1415926535898
#define eps 1e-9
#define MOD 1000000007
#define MAXN 200100
#define N
#define M
//**************************************************************************************
struct Edge
{
int x;
int y;
int z;
};
struct node
{
int x;
int v;
};
vector<node> edge[100001];
int p[100001];
int ran[100001];
int h[100001];
int n,m;
int ans=0;
int ans2=0;
vector<Edge> kiss;
bool cmp(Edge a,Edge b)
{
if(h[a.y]==h[b.y])
return a.z<b.z;
else
return h[a.y]>h[b.y];
}
int fin(int x)
{
if(p[x]==x)
return x;
return p[x]=fin(p[x]);
}
void unite(int x,int y)
{
x=fin(x);
y=fin(y);
if(x==y)
return;
if(ran[x]<ran[y])
p[x]=y;
else
{
p[y]=x;
if(ran[x]==ran[y])
ran[x]++;
}
}
void add_edge(int a,int b,int c)
{
if(h[a]>=h[b])
edge[a].push_back({b,c});
if(h[b]>=h[a])
edge[b].push_back({a,c});
}
int vis[100001];
void bfs()
{
queue<int> q;
vis[1]=1;
q.push(1);
ans=1;
while(!q.empty())
{
int a=q.front();
//cout<<a<<endl;
p[a]=a;
ran[a]=0;
q.pop();
for(int i=0;i<edge[a].size();i++)
{
int u=edge[a][i].x;
kiss.push_back({a,u,edge[a][i].v});
if(vis[u])
continue;
ans++;
vis[u]=1;
q.push(u);
}
}
}
bool same(int x,int y)
{
return fin(x)==fin(y);
}
LL kr()
{
LL ans=0;
std::sort(kiss.begin(),kiss.end(),cmp);
/*
REP(i,kiss.size())
{
cout<<kiss[i].x<<" "<<kiss[i].y<<" "<<kiss[i].z<<endl;
}
*/
REP(i,kiss.size())
{
if(same(kiss[i].x,kiss[i].y))
continue;
ans+=(LL)kiss[i].z;
//cout<<p[kiss[i].x]<<" wwww "<<p[kiss[i].y]<<endl;
//p[kiss[i].y]=kiss[i].x;
unite(kiss[i].x,kiss[i].y);
}
return ans;
}
void init()
{
RD(n),RD(m);
REP_1(i,n)
RD(h[i]);
REP(i,m)
{
int a,b,c;
RD(a),RD(b),RD(c);
add_edge(a,b,c);
}
}
int main()
{
int n,m;
init();
bfs();
cout<<ans<<" "<<kr()<<endl;
}