#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <vector>
#include <stack>
#include <map>
#include <set>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <bitset>
#include <assert.h>
#include <unordered_map>
using namespace std;
typedef long long ll;
#define Cmp(a, b) memcmp(a, b, sizeof(b))
#define Cpy(a, b) memcpy(a, b, sizeof(b))
#define Set(a, v) memset(a, v, sizeof(a))
#define debug(x) cout << #x << ": " << x << endl
#define _forS(i, l, r) for(set<int>::iterator i = (l); i != (r); i++)
#define _rep(i, l, r) for(int i = (l); i <= (r); i++)
#define _for(i, l, r) for(int i = (l); i < (r); i++)
#define _forDown(i, l, r) for(int i = (l); i >= r; i--)
#define debug_(ch, i) printf(#ch"[%d]: %d\n", i, ch[i])
#define debug_m(mp, p) printf(#mp"[%d]: %d\n", p->first, p->second)
#define debugS(str) cout << "dbg: " << str << endl;
#define debugArr(arr, x, y) _for(i, 0, x) { _for(j, 0, y) printf("%c", arr[i][j]); printf("\n"); }
#define _forPlus(i, l, d, r) for(int i = (l); i + d < (r); i++)
#define lowbit(i) (i & (-i))
#define MPR(a, b) make_pair(a, b)
pair<int, int> crack(int n) {
int st = sqrt(n);
int fac = n / st;
while (n % st) {
st += 1;
fac = n / st;
}
return make_pair(st, fac);
}
inline ll qpow(ll a, int n) {
ll ans = 1;
for(; n; n >>= 1) {
if(n & 1) ans *= 1ll * a;
a *= a;
}
return ans;
}
template <class T>
inline bool chmax(T& a, T b) {
if(a < b) {
a = b;
return true;
}
return false;
}
ll gcd(ll a, ll b) {
return b == 0 ? a : gcd(b, a % b);
}
ll ksc(ll a, ll b, ll mod) {
ll ans = 0;
for(; b; b >>= 1) {
if (b & 1) ans = (ans + a) % mod;
a = (a * 2) % mod;
}
return ans;
}
ll ksm(ll a, ll b, ll mod) {
ll ans = 1 % mod;
a %= mod;
for(; b; b >>= 1) {
if (b & 1) ans = ksc(ans, a, mod);
a = ksc(a, a, mod);
}
return ans;
}
template <class T>
inline bool chmin(T& a, T b) {
if(a > b) {
a = b;
return true;
}
return false;
}
template<class T>
bool lexSmaller(vector<T> a, vector<T> b) {
int n = a.size(), m = b.size();
int i;
for(i = 0; i < n && i < m; i++) {
if (a[i] < b[i]) return true;
else if (b[i] < a[i]) return false;
}
return (i == n && i < m);
}
// ============================================================== //
const int maxn = 200000 + 10;
const int maxm = 400000 + 10;
int head[maxn], ver[maxm], ne[maxm], tot = 1, n;
ll edges[maxm];
void add(int a, int b, ll c) {
ver[++tot] = b; edges[tot] = c; ne[tot] = head[a]; head[a] = tot;
}
int vis[maxn], pre[maxn];
ll d[maxn];
void bfs(int u, int &pos) {
memset(vis, 0, sizeof vis);
memset(pre, 0, sizeof pre);
memset(d, 0, sizeof d);
d[u] = 0, vis[u] = 1;
queue<int> q; q.push(u);
while (!q.empty()) {
int x = q.front(); q.pop();
for (int i = head[x]; i; i = ne[i]) {
int y = ver[i];
if (vis[y]) continue;
vis[y] = 1;
pre[y] = x;
d[y] = d[x] + edges[i];
if (d[y] > d[pos]) pos = y;
q.push(y);
}
}
}
typedef pair<int, ll> PII;
vector<PII> a;
ll D[maxn];
ll bfs_max(int u) {
vis[u] = 1;
queue<int> q; q.push(u);
ll res = 0;
while (q.size()) {
int x = q.front(); q.pop();
for (int i = head[x]; i; i = ne[i]) {
int y = ver[i];
if (vis[y]) continue;
vis[y] = 1;
d[y] = d[u] + edges[i];
if (d[y] > res) res = d[y];
q.push(y);
}
}
return res;
}
void diameter() {
int p = 0;
bfs(1, p);
int q = 0;
bfs(p, q);
// [p, q] diameter
while (q) {
a.push_back({q, d[q]});
q = pre[q];
}
reverse(a.begin(), a.end());
// bfs out of diameter
memset(vis, 0, sizeof vis);
for (auto x : a) vis[x.first] = 1;
memset(d, 0, sizeof d);
for (auto x : a) D[x.first] = bfs_max(x.first);
// for (int i = 1; i <= n; i++) printf("%d %lld\n", i, D[i]);
}
void solve() {
ll len = a.back().second - a[0].second;
printf("%lld\n", len);
int l = 0, r = 0;
for (int i = 0; a[i].second-a[0].second <= len/2; i++) {
if (a[i].second-a[0].second == D[a[i].first]) l = i;
}
for (int i = a.size()-1; a.back().second-a[i].second <= len/2; i--) {
if (a.back().second-a[i].second == D[a[i].first]) r = i;
}
// [l+1, r-1]
int ans = max(2, r-l-2);
printf("%d\n", ans);
}
int main() {
//freopen("input.txt", "r", stdin);
scanf("%d", &n);
for (int i = 0; i < n-1; i++) {
int a, b;
ll c;
scanf("%d%d%lld", &a, &b, &c);
add(a, b, c); add(b, a, c);
}
// bfs and diameter
diameter();
solve();
}