#include <iostream>
#include <queue>
#include <cstring>
#include <vector>
using namespace std;
typedef pair<int, int> pii;
const int N = 510;
const int inf = 0x3f3f3f3f;
struct Edge{
int to, wt, nxt;
}edges[N * N + 10];
int book[N], num[N], number[N], cnt[N], head[N], ecnt, dis[N];
int n, m, st, ed;
priority_queue<pii, vector<pii>, greater<pii> > q;
void addedge(int u, int v, int w){
edges[ecnt].to = v;
edges[ecnt].wt = w;
edges[ecnt].nxt = head[u];
head[u] = ecnt++;
}
void dijkstra(){
dis[st] = 0;
cnt[st] = 1;
q.push({0, st});
while(!q.empty()){
int u = q.top().second;
q.pop();
if(book[u]) continue;
book[u] = 1;
for(int i = head[u]; ~i; i = edges[i].nxt){
int v = edges[i].to, w = edges[i].wt;
if(dis[v] > dis[u] + w){
dis[v] = dis[u] + w;
number[v] = number[u] + num[v];
cnt[v] = cnt[u];
q.push({dis[v], v});
}
else if(dis[v] == dis[u] + w){
if(number[v] < number[u] + num[v]){
number[v] = number[u] + num[v];
}
cnt[v] += cnt[u];
}
}
}
return;
}
int main()
{
cin >> n >> m >> st >> ed;
for(int i = 0; i < n; i++){
cin >> num[i];
number[i] = num[i];
}
memset(dis, inf, sizeof dis);
memset(head, -1, sizeof head);
for(int i = 0; i < m; i++){
int a, b, c;
cin >> a >> b >> c;
addedge(a, b, c);
addedge(b, a, c);
}
dijkstra();
cout << cnt[ed] << " " << number[ed];
return 0;
}