/* -*- coding: utf-8 -*- * * 3704.cc: No.3704 豌励∪縺壹>繝壹い (Awkward Pairs) - yukicoder */ #include #include #include using namespace std; /* constant */ const int MAX_N = 200000; const int MAX_N2 = MAX_N * 2; /* typedef */ using ll = long long; using pii = pair; /* global variables */ int as[MAX_N2]; pii ais[MAX_N2]; /* subroutines */ /* main */ int main() { int n; scanf("%d", &n); int n2 = n * 2; for (int i = 0; i < n2; i++) scanf("%d", as + i); for (int i = 0; i < n2; i++) ais[i] = {as[i], i}; sort(ais, ais + n2); ll sum = 0; for (int i = 0; i < n; i++) sum += ais[n2 - 1 - i].first - ais[i].first; printf("%lld\n", sum); for (int i = 0; i < n; i++) printf("%d %d\n", ais[i].second + 1, ais[n2 - 1 - i].second + 1); return 0; }