structnode{ int v, t; booloperator< (const node& b) const{ if (v != b.v) return v > b.v; return t < b.t; } }; int n;
intmain(){ int T; scanf("%d", &T); while (T--){ scanf("%d", &n); ll ans = 0; int cnt = 0; priority_queue<node> q; for (int i = 1, x; i <= n; i++){ scanf("%d", &x); if (q.empty()) q.push({x, 0}); else { int t = q.top().v; if (x > t){ if (q.top().t == 0) cnt += 2; q.pop(); ans += x - t; q.push({x, 0}); q.push({x, 1}); } else q.push({x, 0}); } } printf("%lld %d\n", ans, cnt); } return0; }