#include<bits/stdc++.h>
using namespace std;
long long ans1,ans2;
int cnt,n,m,h[100005],fa[100005];
struct qq
{
int from,to;
long long length;
}p[2000003];
vector<qq> a[100005];
bool flag[100005];
void dfs(int u)
{
flag[u]=1;
++ans1;
for(int i=0;i<a[u].size();++i)
{
int v=a[u][i].to;
p[++cnt].from=u;
p[cnt].to=v;
p[cnt].length=a[u][i].length;
if(!flag[v])
dfs(v);
}
}
bool cmp(qq a,qq b)
{
if(h[a.to]!=h[b.to])
return h[a.to]>h[b.to];
return a.length<b.length;
}
void first()
{
for(int i=1;i<=cnt;++i)
fa[i]=i;
}
int find(int a)
{
return fa[a]==a?a:(fa[a]=find(fa[a]));
}
void kruskal()
{
first();
int now=0;
for(int i=1;i<=cnt;++i)
{
int fu=find(p[i].from);
int fv=find(p[i].to);
if(fu==fv)
continue;
fa[fu]=fv;
ans2+=p[i].length;
++now;
if(now==ans1-1)
break;
}
}
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
cin>>n>>m;
for(int i=1;i<=n;++i)
cin>>h[i];
for(int i=1;i<=m;++i)
{
int f,t,l;
cin>>f>>t>>l;
qq e;
e.length=l;
if(h[f]>=h[t])
{
e.from=f;
e.to=t;
a[f].push_back(e);
}
if(h[t]>=h[f])
{
e.from=t;
e.to=f;
a[t].push_back(e);
}
}
dfs(1);
sort(p+1,p+1+cnt,cmp);
kruskal();
cout<<ans1<<' '<<ans2<<endl;
return 0;
}