//~In The Name Of Allah~//
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <iomanip>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <string.h>
#include <sstream>
#include <cstring>
#include <fstream>
#include <functional>
#include <cstdio>
#include <stack>
#include <utility>
#include <set>
#include <list>
#include <queue>
#include <bitset>
using namespace std;
#define sorta(STL) sort(STL.begin(), STL.end())
#define sortp(STL) sort(STL.begin(), STL.end(), g<ll>())
#define all(STL) STL.begin(), STL.end()
#define mk make_pair
#define ssum(Length) ull(Length*(Length+1)/2)
#define np(Begin, End) next_permutation(Begin, End)
#define gt(Str) getline(cin, Str)
#define g greater
#define re reverse
#define cg cin.get()
#define go continue
#define cinp(number) cin>>number.first>>number.second
#define coutp(number) cout<<number.first<<" "<<number.second<<endl;
#define sp(number) setprecision(number)<<fixed
#define getdis(x1, y1, x2, y2) double(sqrt(pow(x1 - x2, 2) + pow(y1 - y2, 2)))
#define rep(i, j) for (ll i = 0; i < j; i++)
#define rrep(i, size) for (ll i = size - 1; i > -1; i--)
#define Rep(i, j, k) for (ll i = j; i < k; i++)
#define RRep(i, j, size) for (ll i = size - 1; i >= j; i--)
#define mrep(def, mapa) for (def::iterator it = mapa.begin(); it != mapa.end(); it++)
#define pi 3.1415926535897932384626433832795
#define mod 1000000007
#define oo (ll) 1e9
#define ex 2.7182818284
typedef stringstream ss;
typedef string s;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector< vector<int> > vii;
typedef vector<int> vi;
typedef vector<pii> vpii;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<string> vs;
typedef map<int, int> mii;
typedef multimap<int, int> mlii;
typedef map<char, int> mci;
typedef map<string, int> msi;
typedef map<string, string> mss;
typedef map<ll, ll> mlll;
int main(){
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    ll size, mini = 1000000009, maxi = 0, res1, res2 = 0;
    cin >> size;
    vll array(size);
    mlll base;
    rep(i, size){
        cin >> array[i], base[array[i]]++;
        if (maxi < array[i]) maxi = array[i];
        if (mini>array[i]) mini = array[i];
    }
    res1 = maxi - mini;
    if (!res1){
        mrep(mlll, base) res2 += (it->second - 1)*size / 2;
        cout << res1 << " " << res2 << endl;
        return 0;
    }
    mrep(mlll, base)
    for (mlll::iterator itt = it; itt != base.end(); itt++)
    if (it != itt && abs(it->first - itt->first) == res1){
        res2 += it->second* itt->second, it->second = itt->second = 0;
    }
    cout << res1 << " " << res2 << endl;
    return 0;
}


//~In The Name Of Allah~//
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <iomanip>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <string.h>
#include <sstream>
#include <cstring>
#include <fstream>
#include <functional>
#include <cstdio>
#include <stack>
#include <utility>
#include <set>
#include <list>
#include <queue>
#include <bitset>
using namespace std;
#define sorta(STL) sort(STL.begin(), STL.end())
#define sortp(STL) sort(STL.begin(), STL.end(), g<ll>())
#define all(STL) STL.begin(), STL.end()
#define mk make_pair
#define ssum(Length) ull(Length*(Length+1)/2)
#define np(Begin, End) next_permutation(Begin, End)
#define gt(Str) getline(cin, Str)
#define g greater
#define re reverse
#define cg cin.get()
#define go continue
#define cinp(number) cin>>number.first>>number.second
#define coutp(number) cout<<number.first<<" "<<number.second<<endl;
#define sp(number) setprecision(number)<<fixed
#define getdis(x1, y1, x2, y2) double(sqrt(pow(x1 - x2, 2) + pow(y1 - y2, 2)))
#define rep(i, j) for (ll i = 0; i < j; i++)
#define rrep(i, size) for (ll i = size - 1; i > -1; i--)
#define Rep(i, j, k) for (ll i = j; i < k; i++)
#define RRep(i, j, size) for (ll i = size - 1; i >= j; i--)
#define mrep(def, mapa) for (def::iterator it = mapa.begin(); it != mapa.end(); it++)
#define pi 3.1415926535897932384626433832795
#define mod 1000000007
#define oo (ll) 1e9
#define ex 2.7182818284
typedef stringstream ss;
typedef string s;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector< vector<int> > vii;
typedef vector<int> vi;
typedef vector<pii> vpii;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<string> vs;
typedef map<int, int> mii;
typedef map<ll, ll> mll;
typedef multimap<int, int> mlii;
typedef map<char, int> mci;
typedef map<string, int> msi;
typedef map<string, string> mss;
int main(){
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    ll size;
    cin >> size;
    vll array(size);
    mll base;
    rep(i, size) scanf("%ld", &array[i]), base[array[i]]++;
    sorta(array), printf("%ld ", array[size - 1] - array[0]);
    if (array[0] == array[size - 1]) cout << size*(size - 1) / 2 << endl;
    else printf("%ld\n", base[array[0]] * base[array[size - 1]]);
    return 0;
}


//~In The Name Of Allah~//
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <iomanip>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <string.h>
#include <sstream>
#include <cstring>
#include <fstream>
#include <functional>
#include <cstdio>
#include <stack>
#include <utility>
#include <set>
#include <list>
#include <queue>
#include <bitset>
using namespace std;
#define sorta(STL) sort(STL.begin(), STL.end())
#define sortp(STL) sort(STL.begin(), STL.end(), g<ll>())
#define all(STL) STL.begin(), STL.end()
#define mk make_pair
#define ssum(Length) ull(Length*(Length+1)/2)
#define np(Begin, End) next_permutation(Begin, End)
#define gt(Str) getline(cin, Str)
#define g greater
#define re reverse
#define cg cin.get()
#define go continue
#define cinp(number) cin>>number.first>>number.second
#define coutp(number) cout<<number.first<<" "<<number.second<<endl;
#define sp(number) setprecision(number)<<fixed
#define getdis(x1, y1, x2, y2) double(sqrt(pow(x1 - x2, 2) + pow(y1 - y2, 2)))
#define rep(i, j) for (ll i = 0; i < j; i++)
#define rrep(i, size) for (ll i = size - 1; i > -1; i--)
#define Rep(i, j, k) for (ll i = j; i < k; i++)
#define RRep(i, j, size) for (ll i = size - 1; i >= j; i--)
#define mrep(def, mapa) for (def::iterator it = mapa.begin(); it != mapa.end(); it++)
#define pi 3.1415926535897932384626433832795
#define mod 1000000007
#define oo (ll) 1e9
#define ex 2.7182818284
typedef stringstream ss;
typedef string s;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector< vector<int> > vii;
typedef vector<int> vi;
typedef vector<pii> vpii;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<string> vs;
typedef map<int, int> mii;
typedef map<ll, ll> mll;
typedef multimap<int, int> mlii;
typedef map<char, int> mci;
typedef map<string, int> msi;
typedef map<string, string> mss;
int main(){
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    ll size;
    cin >> size;
    vll array(size);
    mll base;
    rep(i, size) scanf("%ld", &array[i]), base[array[i]]++;
    sorta(array), cout << array[size - 1] - array[0] << " ";
    if (array[0] == array[size - 1]) cout << size*(size - 1) / 2 << endl;
    else cout << base[array[0]] * base[array[size - 1]] << endl;
    return 0;
}


//~In The Name Of Allah~//
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <iomanip>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <string.h>
#include <sstream>
#include <cstring>
#include <fstream>
#include <functional>
#include <cstdio>
#include <stack>
#include <utility>
#include <set>
#include <list>
#include <queue>
#include <bitset>
using namespace std;

#define all(S) S.begin(), S.end()
#define sortb(S) sort(all(S), greater<ll>())
#define sorta(S) sort(all(S))
#define cinp(N) cin>>N.first>>N.second
#define coutp(N) cout<<N.first<<" "<<N.second<<endl
#define mem(C, V) memset(C, V, sizeof C)
#define clr(S, V) fill(all(S), V)
#define ssum(N) (ll)N*(N+1)/2
#define gt(S) getline(cin, S)
#define sp(N) setprecision(N)<<fixed
#define siz(S) S.size()
#define mk make_pair
#define go continue
#define rep(i, j) for (ll i = 0; i < j; i++)
#define rrep(i, j) for (ll i = j - 1; i > -1; i--)
#define getdis(x1, y1, x2, y2) double(sqrt(pow(x1 - x2, 2) + pow(y1 - y2, 2)))
#define Rep(i, j, k) for (ll i = j; i < k; i++)
#define srep(C) for (decltype(C.begin()) it = C.begin(); it != C.end(); it++)
#define pi 3.1415926535897932384626433832795
#define ex 2.7182818284
#define mod 1000000007
#define oo (ll) 1e9

typedef stringstream  ss;
typedef string            s;
typedef long long       ll;
typedef pair<int, int>  pii;
typedef vector<int>     vi;
typedef vector<vi>      vii;
typedef vector<pii>     vpii;
typedef vector<ll>       vll;
typedef vector<bool>  vb;
typedef vector<s>       vs;
typedef map<ll, ll>      mii;
typedef map<char, ll> mci;
typedef map<s, ll>      msi;

int base[(int)2e5 + 1] = { 0 };
int main(){
    //freopen("input.cpp", "r", stdin);
    //freopen("output.cpp", "w", stdout);
    int size;
    cin >> size;
    vi array(size);
    rep(i, size) scanf("%d", &array[i]), base[array[i]]++;
    sorta(array);
    cout << array[size - 1] - array[0] << " " << (ll)base[array[size - 1]] * base[array[0]] << endl;
    return 0;
}


//~In The Name Of Allah~//
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <iomanip>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <string.h>
#include <sstream>
#include <cstring>
#include <fstream>
#include <functional>
#include <cstdio>
#include <stack>
#include <utility>
#include <set>
#include <list>
#include <queue>
#include <bitset>
using namespace std;

#define all(S) S.begin(), S.end()
#define sortb(S) sort(all(S), greater<ll>())
#define sorta(S) sort(all(S))
#define cinp(N) cin>>N.first>>N.second
#define coutp(N) cout<<N.first<<" "<<N.second<<endl
#define mem(C, V) memset(C, V, sizeof C)
#define clr(S, V) fill(all(S), V)
#define ssum(N) (ll)N*(N+1)/2
#define gt(S) getline(cin, S)
#define sp(N) setprecision(N)<<fixed
#define siz(S) S.size()
#define mk make_pair
#define go continue
#define rep(i, j) for (ll i = 0; i < j; i++)
#define rrep(i, j) for (ll i = j - 1; i > -1; i--)
#define getdis(x1, y1, x2, y2) double(sqrt(pow(x1 - x2, 2) + pow(y1 - y2, 2)))
#define Rep(i, j, k) for (ll i = j; i < k; i++)
#define srep(C) for (decltype(C.begin()) it = C.begin(); it != C.end(); it++)
#define pi 3.1415926535897932384626433832795
#define ex 2.7182818284
#define mod 1000000007
#define oo (ll) 1e9

typedef stringstream  ss;
typedef string            s;
typedef long long       ll;
typedef pair<int, int>  pii;
typedef vector<int>     vi;
typedef vector<vi>      vii;
typedef vector<pii>     vpii;
typedef vector<ll>       vll;
typedef vector<bool>  vb;
typedef vector<s>       vs;
typedef map<ll, ll>      mii;
typedef map<char, ll> mci;
typedef map<s, ll>      msi;

int main(){
    //freopen("input.cpp", "r", stdin);
    //freopen("output.cpp", "w", stdout);
    int size;
    cin >> size;
    vi array(size);
    mii base;
    rep(i, size) scanf("%d", &array[i]), base[array[i]]++;
    sorta(array);
    if (array[0] == array[size - 1]) cout << array[size - 1] - array[0] << " " << (ll)base[array[0]] * (base[array[0]] - 1) / 2 << endl;
    else cout << array[size - 1] - array[0] << " " << (ll)base[array[size - 1]] * base[array[0]] << endl;
    return 0;
}


//~In The Name Of Allah~//
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <iomanip>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <string.h>
#include <sstream>
#include <cstring>
#include <fstream>
#include <functional>
#include <cstdio>
#include <stack>
#include <utility>
#include <set>
#include <list>
#include <queue>
#include <bitset>
using namespace std;
#define sorta(STL) sort(STL.begin(), STL.end())
#define sortb(STL) sort(STL.begin(), STL.end(), g<ll>())
#define all(STL) STL.begin(), STL.end()
#define ssum(Length) ull(Length*(Length+1)/2)
#define np(Begin, End) next_permutation(Begin, End)
#define cinp(number) cin>>number.first>>number.second
#define coutp(number) cout<<number.first<<" "<<number.second<<endl
#define sp(number) setprecision(number)<<fixed
#define getdis(x1, y1, x2, y2) double(sqrt(pow(x1 - x2, 2) + pow(y1 - y2, 2)))
#define rep(i, j) for (ll i = 0; i < j; i++)
#define rrep(i, size) for (ll i = size - 1; i > -1; i--)
#define Rep(i, j, k) for (ll i = j; i < k; i++)
#define RRep(i, j, size) for (ll i = size - 1; i >= j; i--)
#define mrep(def, mapa) for (def::iterator it = mapa.begin(); it != mapa.end(); it++)
#define mem(Array, Val) memset(Array, Val, sizeof Array)
#define clr(Stl, Val) fill(all(Stl), Val)
#define gt(Str) getline(cin, Str)
#define mk make_pair
#define g greater
#define cg cin.get()
#define go continue
#define pi 3.1415926535897932384626433832795
#define mod 1000000007
#define oo (ll) 1e9
#define ex 2.7182818284
typedef stringstream ss;
typedef string s;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<vector<int> > vii;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<pii> vpii;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<string> vs;
typedef map<ll, ll> mii;
typedef set<int> si;
typedef multimap<int, int> mlii;
typedef map<char, ll> mci;
typedef map<string, ll> msi;
typedef map<string, string> mss;
int main(){
    //freopen("input.cpp", "r", stdin);
    //freopen("output.cpp", "w", stdout);
    int size;
    cin >> size;
    vi array(size);
    mii base;
    rep(i, size) scanf("%d", &array[i]), base[array[i]]++;
    sorta(array), printf("%d %d\n", array[size - 1] - array[0], base[array[0]] * base[array[size - 1]]);
    return 0;
}


//~In The Name Of Allah~//
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <iomanip>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <string.h>
#include <sstream>
#include <cstring>
#include <fstream>
#include <functional>
#include <cstdio>
#include <stack>
#include <utility>
#include <set>
#include <list>
#include <queue>
#include <bitset>
using namespace std;
#define sorta(STL) sort(STL.begin(), STL.end())
#define sortp(STL) sort(STL.begin(), STL.end(), g<ll>())
#define all(STL) STL.begin(), STL.end()
#define mk make_pair
#define ssum(Length) ull(Length*(Length+1)/2)
#define np(Begin, End) next_permutation(Begin, End)
#define gt(Str) getline(cin, Str)
#define g greater
#define re reverse
#define cg cin.get()
#define go continue
#define cinp(number) cin>>number.first>>number.second
#define coutp(number) cout<<number.first<<" "<<number.second<<endl;
#define sp(number) setprecision(number)<<fixed
#define getdis(x1, y1, x2, y2) double(sqrt(pow(x1 - x2, 2) + pow(y1 - y2, 2)))
#define rep(i, j) for (ll i = 0; i < j; i++)
#define rrep(i, size) for (ll i = size - 1; i > -1; i--)
#define Rep(i, j, k) for (ll i = j; i < k; i++)
#define RRep(i, j, size) for (ll i = size - 1; i >= j; i--)
#define mrep(def, mapa) for (def::iterator it = mapa.begin(); it != mapa.end(); it++)
#define pi 3.1415926535897932384626433832795
#define mod 1000000007
#define oo (ll) 1e9
#define ex 2.7182818284
typedef stringstream ss;
typedef string s;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector< vector<int> > vii;
typedef vector<int> vi;
typedef vector<pii> vpii;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<string> vs;
typedef map<int, int> mii;
typedef multimap<int, int> mlii;
typedef map<char, int> mci;
typedef map<string, int> msi;
typedef map<string, string> mss;
int main(){
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int size, mini = oo + 10, maxi = 0, res1, res2 = 0;
    cin >> size;
    vi array(size);
    rep(i, size){
        cin >> array[i];
        if (maxi < array[i]) maxi = array[i];
        if (mini>array[i]) mini = array[i];
    }
    res1 = maxi - mini;
    rep(i, size - 1) Rep(j, i, size) if (abs(array[i] - array[j]) == res1) res2++;
    cout << res1 << " " << res2 << endl;
    return 0;
}


//~In The Name Of Allah~//
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <iomanip>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <string.h>
#include <sstream>
#include <cstring>
#include <fstream>
#include <functional>
#include <cstdio>
#include <stack>
#include <utility>
#include <set>
#include <list>
#include <queue>
#include <bitset>
using namespace std;
#define sorta(STL) sort(STL.begin(), STL.end())
#define sortp(STL) sort(STL.begin(), STL.end(), g<ll>())
#define all(STL) STL.begin(), STL.end()
#define mk make_pair
#define ssum(Length) ull(Length*(Length+1)/2)
#define np(Begin, End) next_permutation(Begin, End)
#define gt(Str) getline(cin, Str)
#define g greater
#define re reverse
#define cg cin.get()
#define go continue
#define cinp(number) cin>>number.first>>number.second
#define coutp(number) cout<<number.first<<" "<<number.second<<endl;
#define sp(number) setprecision(number)<<fixed
#define getdis(x1, y1, x2, y2) double(sqrt(pow(x1 - x2, 2) + pow(y1 - y2, 2)))
#define rep(i, j) for (ll i = 0; i < j; i++)
#define rrep(i, size) for (ll i = size - 1; i > -1; i--)
#define Rep(i, j, k) for (ll i = j; i < k; i++)
#define RRep(i, j, size) for (ll i = size - 1; i >= j; i--)
#define mrep(def, mapa) for (def::iterator it = mapa.begin(); it != mapa.end(); it++)
#define pi 3.1415926535897932384626433832795
#define mod 1000000007
#define oo (ll) 1e9
#define ex 2.7182818284
typedef stringstream ss;
typedef string s;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector< vector<int> > vii;
typedef vector<int> vi;
typedef vector<pii> vpii;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<string> vs;
typedef map<int, int> mii;
typedef multimap<int, int> mlii;
typedef map<char, int> mci;
typedef map<string, int> msi;
typedef map<string, string> mss;
int main(){
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int size, mini = oo + 10, maxi = 0, res1, res2 = 0;
    cin >> size;
    vi array(size);
    mii base;
    rep(i, size){
        cin >> array[i], base[array[i]]++;
        if (maxi < array[i]) maxi = array[i];
        if (mini>array[i]) mini = array[i];
    }
    res1 = maxi - mini;
    mrep(mii, base){
        for (mii::iterator itt = it; itt != base.end(); itt++) if (it != itt && abs(it->first - itt->first) == res1) res2 += it->second* itt->second;
    }
    cout << res1 << " " << res2 << endl;
    return 0;
}


#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
using namespace std;
int a[2000000];
int main()
{
    long long n;
    while(~scanf("%I64d",&n))
    {
        int min=1000000009;
        int max=-1;
        for(int i=0;i<n;i++)
        {
            scanf("%d",&a[i]);
        }
        for(int i=0;i<n;i++)
        {
            if(min>=a[i]){min=a[i];}
            if(max<=a[i]){max=a[i];}
        }
        long long c=0,cc=0;
        for(int i=0;i<n;i++)
        {
            if(a[i]==min){c++;}
            if(a[i]==max){cc++;}
        }
        if(max==min){cout<<"0 "<<n*(n-1)/2<<endl;}
        else
        {
            cout<<max-min<<" "<<c*cc<<endl;
        }
    }
    return 0;
}


#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
using namespace std;
int a[200000000];
int main()
{
    int n,k=0;
    while(~scanf("%d",&n))
    {
        k++;
        int min=1000000009;
        int max=-1;
        scanf("%d",&a[0]);
        for(long long i=1;i<n;i++)
        {
            scanf("%d",&a[i]);
        }
        int ok=0;
        for(long long i=1;i<n;i++)
        {
            if(a[i]!=a[i-1]){ok=1;break;}
        }
        for(long long i=0;i<n;i++)
        {
            if(min>=a[i]){min=a[i];}
            if(max<=a[i]){max=a[i];}
        }
        long long c=0,cc=0;
        for(long long i=0;i<n;i++)
        {
            if(a[i]==min){c++;}
            if(a[i]==max){cc++;}
        }
        //cout<<ok<<endl;
        if(ok==0){cout<<"0 "<<n*(n-1)/2<<endl;}
        else
        {
            cout<<max-min<<" "<<c*cc<<endl;
        }
    }
    return 0;
}


#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
using namespace std;
int a[2000000];
int main()
{
    int n;
    while(~scanf("%d",&n))
    {
        int min=1000000009;
        int max=-1;
        scanf("%d",&a[0]);
        int ok=0;
        for(int i=1;i<n;i++)
        {
            scanf("%d",&a[i]);
        }
        for(int i=1;i<n;i++)
        {
            if(a[i]!=a[i-1]){ok=1;break;}
        }
        for(int i=0;i<n;i++)
        {
            if(min>a[i]){min=a[i];}
            else if(max<a[i]){max=a[i];}
        }
        long long c=0,cc=0;
        for(int i=0;i<n;i++)
        {
            if(a[i]==min){c++;}
            else if(a[i]==max){cc++;}
        }
        long long mm=c*cc;
        long long mmm=n*(n-1)/2;
        if(ok==0){cout<<"0 "<<mmm<<endl;}
        else
        {
            cout<<max-min<<" "<<mm<<endl;
        }
    }
    return 0;
}


#include<stdio.h>
#include<algorithm>
using namespace std;
long long int t,s[200010],i;
long long int jc(long long int x)
{
    if(x==1||x==0) return 1;
    else return x*jc(x-1);
}
long long int c(long long int x,long long int y)
{
    return jc(x)/(jc(y)*jc(x-y));
}
int main()
{

    while(~scanf("%I64d",&t))
    {
        for(i=0;i<t;i++)
            scanf("%I64d",&s[i]);
        sort(s,s+t);
        long long int minnum=1,maxnum=1;
        for(i=1;i<t;i++)
        {
            if(s[i]!=s[i-1])
                break;
            minnum++;
        }
        for(i=t-2;i>=0;i--)
        {
            if(s[i]!=s[i+1])
                break;
            maxnum++;
        }
        if(s[t-1]-s[0]==0)
        {
            printf("0 %I64d\n",c(t,2));
            continue;
        }
        printf("%I64d %I64d\n",s[t-1]-s[0],minnum*maxnum);
    }
}


#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
long long a[200000];
int main()
{
    long long n;
    while(cin>>n)
    {
        for(int i=0;i<n;i++)
        {
            cin>>a[i];
        }
        int max=a[0];
        int min=a[0];
        for(int i=1;i<n;i++)
        {
            if(max<a[i]){max=a[i];}
            if(min>a[i]){min=a[i];}
        }
        long long c=0;
        long long cc=0;
        for(int i=0;i<n;i++)
        {
            if(a[i]==min){c++;}
            if(a[i]==max){cc++;}
        }
        if(max==min){cout<<"0 "<<n*(n-1)/2<<endl;}
        else {cout<<max-min<<" "<<cc*c<<endl;}
    }
}


#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
using namespace std;
int a[2000000];
int main()
{
    int n;
    while(~scanf("%d",&n))
    {
        int min=1000000009;
        int max=-1;
        scanf("%d",&a[0]);
        int ok=0;
        for(int i=1;i<n;i++)
        {
            scanf("%d",&a[i]);
        }
        for(int i=1;i<n;i++)
        {
            if(a[i]!=a[i-1]){ok=1;break;}
        }
        for(int i=0;i<n;i++)
        {
            if(min>a[i]){min=a[i];}
            else if(max<a[i]){max=a[i];}
        }
        long long c=0,cc=0;
        for(int i=0;i<n;i++)
        {
            if(a[i]==min){c++;}
            else if(a[i]==max){cc++;}
        }
        long long mm=c*cc;
        if(ok==0){cout<<"0 0"<<endl;}
        else
        {
            cout<<max-min<<" "<<mm<<endl;
        }
    }
    return 0;
}


#include<stdio.h>
#include<math.h>
#include<string.h>
#include<iostream>
#include<algorithm>
using namespace std;
int a[2000009];
int main()
{
    int n;
    while(scanf("%d",&n)!=EOF)
    {
        __int64 max1=0,min1=10000000000,s=0,e=0;
        for(int i=1;i<=n;i++)
        {
            scanf("%d",&a[i]);
            if(a[i]>max1)
            {
                max1=a[i];
                e=1;
            }
            else if(a[i]==max1)
            {
                e++;
            }
            if(a[i]<min1)
            {
                min1=a[i];
                s=1;
            }
            else if(a[i]==min1)
            {
                s++;
            }
        }
        __int64 sum=s*e;
        if(max1==min1)
            sum=(n-1)*n/2;
        printf("%I64d %I64d\n",max1-min1,sum);
    }
    return 0;
}


#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
using namespace std;
int a[2000000];
int main()
{
    int n;
    while(~scanf("%d",&n))
    {
        for(long long i=0;i<n;i++)
        {
            scanf("%d",&a[i]);
        }
        int min=a[0];
        int max=a[0];
        int ok=0;
        for(long long i=1;i<n;i++)
        {
            if(a[i]!=a[i-1]){ok=1;break;}
        }
        for(long long i=0;i<n;i++)
        {
            if(min>a[i]){min=a[i];}
            if(max<a[i]){max=a[i];}
        }
        long long c=0,cc=0;
        for(long long i=0;i<n;i++)
        {
            if(a[i]==min){c++;}
            if(a[i]==max){cc++;}
        }
        if(ok==0){cout<<"0 "<<n*(n-1)/2<<endl;}
        else
        {
            cout<<max-min<<" "<<c*cc<<endl;
        }
    }
    return 0;
}


#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
using namespace std;
int a[200000000];
int main()
{
    int n;
    while(~scanf("%d",&n))
    {
        for(long long i=0;i<n;i++)
        {
            scanf("%d",&a[i]);
        }
        int min=a[0];
        int max=a[0];
        int ok=0;
        for(long long i=1;i<n;i++)
        {
            if(a[i]!=a[i-1]){ok=1;break;}
        }
        for(long long i=0;i<n;i++)
        {
            if(min>a[i]){min=a[i];}
            if(max<a[i]){max=a[i];}
        }
        long long c=0,cc=0;
        for(long long i=0;i<n;i++)
        {
            if(a[i]==min){c++;}
            if(a[i]==max){cc++;}
        }
        if(ok==0){cout<<"0 "<<n*(n-1)/2<<endl;}
        else
        {
            cout<<max-min<<" "<<c*cc<<endl;
        }
    }
    return 0;
}


#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
using namespace std;
int a[2000000];
int main()
{
    int n;
    while(~scanf("%d",&n))
    {
        int min=1000000009;
        int max=-1;
        scanf("%d",&a[0]);
        int ok=0;
        for(int i=1;i<n;i++)
        {
            scanf("%d",&a[i]);
        }
        for(int i=1;i<n;i++)
        {
            if(a[i]!=a[i-1]){ok=1;break;}
        }
        for(int i=0;i<n;i++)
        {
            if(min>a[i]){min=a[i];}
            else if(max<a[i]){max=a[i];}
        }
        int c=0,cc=0;
        for(int i=0;i<n;i++)
        {
            if(a[i]==min){c++;}
            else if(a[i]==max){cc++;}
        }
        if(ok==0){cout<<"0 0"<<endl;}
        else
        {
            cout<<max-min<<" "<<c*cc<<endl;
        }
    }
    return 0;
}


#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
using namespace std;
int a[200000000];
int main()
{
    int n,k=0;
    while(~scanf("%d",&n))
    {
        k++;
        int min=1000000009;
        int max=-1;
        scanf("%d",&a[0]);
        for(long long i=1;i<n;i++)
        {
            scanf("%d",&a[i]);
        }
        for(long long i=0;i<n;i++)
        {
            if(min>=a[i]){min=a[i];}
            if(max<=a[i]){max=a[i];}
        }
        long long c=0,cc=0;
        for(long long i=0;i<n;i++)
        {
            if(a[i]==min){c++;}
            if(a[i]==max){cc++;}
        }
        if(k==6){cout<<max<<" "<<min<<endl;}
        if(max==min){cout<<"0 "<<n*(n-1)/2<<endl;}
        else
        {
            cout<<max-min<<" "<<c*cc<<endl;
        }
    }
    return 0;
}


#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
using namespace std;
int a[20005];
int main()
{
    int n;
    while(~scanf("%d",&n))
    {
        int min=1000000009;
        int max=-1;
        scanf("%d",&a[0]);
        int ok=0;
        for(int i=1;i<n;i++)
        {
            scanf("%d",&a[i]);
        }
        for(int i=1;i<n;i++)
        {
            if(a[i]!=a[i-1]){ok=1;}
        }
        for(int i=0;i<n;i++)
        {
            if(min>a[i]){min=a[i];}
            else if(max<a[i]){max=a[i];}
        }
        int c=0,cc=0;
        for(int i=0;i<n;i++)
        {
            if(a[i]==min){c++;}
            else if(a[i]==max){cc++;}
        }
        if(ok==0){cout<<0<<" "<<0<<endl;}
        else
        {
            cout<<max-min<<" "<<c*cc<<endl;
        }

    }
}


#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
using namespace std;
int a[2000000];
int main()
{
    long long n;
    while(~scanf("%d",&n))
    {
        int min=1000000009;
        int max=-1;
        for(int i=0;i<n;i++)
        {
            scanf("%d",&a[i]);
        }
        for(int i=0;i<n;i++)
        {
            if(min>=a[i]){min=a[i];}
            if(max<=a[i]){max=a[i];}
        }
        long long c=0,cc=0;
        for(int i=0;i<n;i++)
        {
            if(a[i]==min){c++;}
            if(a[i]==max){cc++;}
        }
        if(max==min){cout<<"0 "<<n*(n-1)/2<<endl;}
        else
        {
            cout<<max-min<<" "<<c*cc<<endl;
        }
    }
    return 0;
}


#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
using namespace std;
int a[2000000];
int main()
{
    int n;
    while(~scanf("%d",&n))
    {
        int min=1000000009;
        int max=-1;
        scanf("%d",&a[0]);
        for(long long i=1;i<n;i++)
        {
            scanf("%d",&a[i]);
        }
        for(long long i=0;i<n;i++)
        {
            if(min>=a[i]){min=a[i];}
            if(max<=a[i]){max=a[i];}
        }
        long long c=0,cc=0;
        for(long long i=0;i<n;i++)
        {
            if(a[i]==min){c++;}
            if(a[i]==max){cc++;}
        }
        if(max==min){cout<<"0 "<<n*(n-1)/2<<endl;}
        else
        {
            cout<<max-min<<" "<<c*cc<<endl;
        }
    }
    return 0;
}


#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
using namespace std;
long long a[2000000];
int main()
{
    long long n;
    while(~scanf("%d",&n))
    {
        for(long long i=0;i<n;i++)
        {
            scanf("%d",&a[i]);
        }
        int min=a[0];
        int max=a[0];
        for(long long i=1;i<n;i++)
        {
            if(a[i]!=a[i-1]){ok=1;break;}
        }
        for(long long i=0;i<n;i++)
        {
            if(min>a[i]){min=a[i];}
            if(max<a[i]){max=a[i];}
        }
        long long c=0,cc=0;
        for(long long i=0;i<n;i++)
        {
            if(a[i]==min){c++;}
            if(a[i]==max){cc++;}
        }
        if(max==min){cout<<"0 "<<n*(n-1)/2<<endl;}
        else
        {
            cout<<max-min<<" "<<c*cc<<endl;
        }
    }
    return 0;
}


#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
using namespace std;
long long a[2000000];
int main()
{
    long long n;
    while(~scanf("%d",&n))
    {
        for(long long i=0;i<n;i++)
        {
            scanf("%d",&a[i]);
        }
        int min=a[0];
        int max=a[0];
        for(long long i=0;i<n;i++)
        {
            if(min>a[i]){min=a[i];}
            if(max<a[i]){max=a[i];}
        }
        long long c=0,cc=0;
        for(long long i=0;i<n;i++)
        {
            if(a[i]==min){c++;}
            if(a[i]==max){cc++;}
        }
        if(max==min){cout<<"0 "<<n*(n-1)/2<<endl;}
        else
        {
            cout<<max-min<<" "<<c*cc<<endl;
        }
    }
    return 0;
}


#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
using namespace std;
int a[2000000];
int main()
{
    int n;
    while(~scanf("%d",&n))
    {
        int min=1000000009;
        int max=-1;
        scanf("%d",&a[0]);
        int ok=0;
        for(int i=1;i<n;i++)
        {
            scanf("%d",&a[i]);
        }
        for(int i=0;i<n;i++)
        {
            if(min>=a[i]){min=a[i];}
            if(max<=a[i]){max=a[i];}
        }
        long long c=0,cc=0;
        for(int i=0;i<n;i++)
        {
            if(a[i]==min){c++;}
            else if(a[i]==max){cc++;}
        }
        long long mm=c*cc;
        long long mmm=n*(n-1)/2;
        if(max==min){cout<<"0 "<<mmm<<endl;}
        else
        {
            cout<<max-min<<" "<<mm<<endl;
        }
    }
    return 0;
}


#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
using namespace std;
int a[1000000];
int main()
{
    int n;
    while(cin>>n)
    {
        int min=10000000000;
        int max=-10000000000;
        for(int i=0;i<n;i++)
        {
            cin>>a[i];
            if(min>a[i]){min=a[i];}
            if(max<a[i]){max=a[i];}
        }
        int c=0,cc=0;
        for(int i=0;i<n;i++)
        {
            if(a[i]==min){c++;}
            else if(a[i]==max){cc++;}
        }
        cout<<max-min<<" "<<c*cc<<endl;
    }
}


#include<bits/stdc++.h>
using namespace std;
vector<int> v;
int main()
{
int k;
cin>>k;
unsigned long long int a[k],mn=9999999999999999999,mx=0,mn1=0,mx1=0;
for(int i=0;i<k;i++)
{
	int n;
	cin>>n;
	if(n<mn)
	{
		mn=n;
		mn1=1;
	}
	else if(n==mn)
	{
		mn1++;
	}
	if(n>mx)
	{
		mx=n;
		mx1=1;
	}
	else if(n==mx)
	{
		mx1++;
	}
}
if(mn==mx&&k!=2)
{
	cout<<0<<" "<<(mn1*(mx-1))/2;
}
else if(k==2)
{
	cout<<mx-mn<<" "<<1;
}
else
{
	cout<<mx-mn<<" "<<mx1*mn1;
}
}


#include<bits/stdc++.h>
using namespace std;
long long int a[200100];
int main()
{
long long int n,mn=1000000002,mx=-1000000002,mn1=0,mx1=0;
cin>>n;
for(int i=0;i<n;i++)
{
	cin>>a[i];
	mn=min(mn,a[i]);
	mx=max(mx,a[i]);
}
for(int i=0;i<n;i++)
{
if(a[i]==mn)mn1++;
if(a[i]==mx)mx1++;
}
cout<<mx-mn<<" ";
if(n==2 && mn==mx)cout<<1;
	else if(mn==mx)cout<<mn1*(mx1-1)/2;
	else cout<<mx1*mn1;
}


#include<bits/stdc++.h>
using namespace std;
long long int a[200100];
int main()
{
long long int n,mn=100000000,mx=-1000000000,mn1=0,mx1=0;
cin>>n;
for(int i=0;i<n;i++)
{
	cin>>a[i];
	mn=min(mn,a[i]);
	mx=max(mx,a[i]);
}
for(int i=0;i<n;i++)
{
if(a[i]==mn)mn1++;
if(a[i]==mx)mx1++;
}
cout<<mx-mn<<" "<<min(mn1,mx1);
}


#include<bits/stdc++.h>
using namespace std;
vector<int> v;
int main()
{
int k;
cin>>k;
int a[k],mn=9999999,mx=0,mn1=0,mx1=0;
for(int i=0;i<k;i++)
{
	int n;
	cin>>n;
	if(n<mn)
	{
		mn=n;
		mn1=1;
	}
	else if(n==mn)
	{
		mn1++;
	}
	if(n>mx)
	{
		mx=n;
		mx1=1;
	}
	else if(n==mx)
	{
		mx1++;
	}
}
if(mn==mx&&k!=2)
{
	cout<<0<<" "<<(k*(k	-1))/2;
}
else if(k==2)
{
	cout<<mx-mn<<" "<<1;
}
else
{
	cout<<mx-mn<<" "<<mx1*mn1;
}
}
//0


#include<bits/stdc++.h>
using namespace std;
long long int a[200100];
int main()
{
long long int n,mn=100000000,mx=-1000000000,mn1=0,mx1=0;
cin>>n;
for(int i=0;i<n;i++)
{
	cin>>a[i];
	mn=min(mn,a[i]);
	mx=max(mx,a[i]);
}
for(int i=0;i<n;i++)
{
if(a[i]==mn)mn1++;
if(a[i]==mx)mx1++;
}
if(n==2 && mn==mx)cout<<1;
	else if(mn==mx)cout<<mn1*(mx1-1)/2;
	else cout<<mx1*mn1;
}


#include<bits/stdc++.h>
using namespace std;
vector<int> v;
int main()
{
int k;
cin>>k;
long long int a[k],mn=999999999999,mx=0,mn1=0,mx1=0;
for(int i=0;i<k;i++)
{
	int n;
	cin>>n;
	if(n<mn)
	{
		mn=n;
		mn1=1;
	}
	else if(n==mn)
	{
		mn1++;
	}
	if(n>mx)
	{
		mx=n;
		mx1=1;
	}
	else if(n==mx)
	{
		mx1++;
	}
}
if(mn==mx&&k!=2)
{
	cout<<0<<" "<<(mn1*(mx-1))/2;
}
else if(k==2)
{
	cout<<mx-mn<<" "<<1;
}
else
{
	cout<<mx-mn<<" "<<mx1*mn1;
}
}
//0


#include<bits/stdc++.h>
using namespace std;
vector<int> v;
int main()
{
int k;
cin>>k;
unsigned long long int a[k],mn=1e9,mx=0,mn1=0,mx1=0;
for(int i=0;i<k;i++)
{
	int n;
	cin>>n;
	if(n<mn)
	{
		mn=n;
		mn1=1;
	}
	else if(n==mn)
	{
		mn1++;
	}
	if(n>mx)
	{
		mx=n;
		mx1=1;
	}
	else if(n==mx)
	{
		mx1++;
	}
}
if(mn==mx&&k!=2)
{
	cout<<0<<" "<<(mn1*(mx-1))/2;
}
else if(k==2)
{
	cout<<mx-mn<<" "<<1;
}
else
{
	cout<<mx-mn<<" "<<mx1*mn1;
}
}


#include<bits/stdc++.h>
using namespace std;
long long int a[200100];
int main()
{
long long int n,mn=100000000,mx=-1000000000,mn1=0,mx1=0;
cin>>n;
for(int i=0;i<n;i++)
{
	cin>>a[i];
	mn=min(mn,a[i]);
	mx=max(mx,a[i]);
}
for(int i=0;i<n;i++)
{
if(a[i]==mn)mn1++;
if(a[i]==mx)mx1++;
}
cout<<mx-mn<<" ";
if(n==2 && mn==mx)cout<<1;
	else if(mn==mx)cout<<mn1*(mx1-1)/2;
	else cout<<mx1*mn1;
}


#include<bits/stdc++.h>
using namespace std;
vector<int> v;
int main()
{
int k;
cin>>k;
unsigned long long int a[k],mn=999999999999,mx=0,mn1=0,mx1=0;
for(int i=0;i<k;i++)
{
	int n;
	cin>>n;
	if(n<mn)
	{
		mn=n;
		mn1=1;
	}
	else if(n==mn)
	{
		mn1++;
	}
	if(n>mx)
	{
		mx=n;
		mx1=1;
	}
	else if(n==mx)
	{
		mx1++;
	}
}
if(mn==mx&&k!=2)
{
	cout<<0<<" "<<(k*(k	-1))/2;
}
else if(k==2)
{
	cout<<mx-mn<<" "<<1;
}
else
{
	cout<<mx-mn<<" "<<mx1*mn1;
}
}
//0


#include<bits/stdc++.h>
using namespace std;
	ll a,n[200100],mn=1e9,mx=-1e9,z,x;
int main(){
	cin>>a;
	for(int i=0;i<a;i++){
		cin>>n[i];
		mn=min(mn,n[i]);
		mx=max(mx,n[i]);
	}
	cout<<mx-mn<<" ";
	for(int i=0;i<a;i++){
		if(n[i]==mn)z++;
		if(n[i]==mx)x++;
	}
	if(a==2 && mn==mx)cout<<1;
	else if(mn==mx)cout<<z*(x-1)/2;
	else cout<<z*x;
}


#include<bits/stdc++.h>
using namespace std;
vector<int> v;
int main()
{
int k;
cin>>k;
unsigned long long int a[k],mn=9999999,mx=0,mn1=0,mx1=0;
for(int i=0;i<k;i++)
{
	int n;
	cin>>n;
	if(n<mn)
	{
		mn=n;
		mn1=1;
	}
	else if(n==mn)
	{
		mn1++;
	}
	if(n>mx)
	{
		mx=n;
		mx1=1;
	}
	else if(n==mx)
	{
		mx1++;
	}
}
if(mn==mx&&k!=2)
{
	cout<<0<<" "<<(k*(k	-1))/2;
}
else if(k==2)
{
	cout<<mx-mn<<" "<<1;
}
else
{
	cout<<mx-mn<<" "<<mx1*mn1;
}
}
//0


#include<bits/stdc++.h>
using namespace std;
long long int a[200100];
int main()
{
long long int n,mn=100000000,mx=-1000000000,mn1=0,mx1=0;
cin>>n;
for(int i=0;i<n;i++)
{
	cin>>a[i];
	mn=min(mn,a[i]);
	mx=max(mx,a[i]);
}
for(int i=0;i<n;i++)
{
if(a[i]==mn)mn1++;
if(a[i]==mx)mx1++;
}
cout<<min(mn1,mx1);
}


#include<bits/stdc++.h>
using namespace std;
vector<int> v;
int main()
{
int k;
cin>>k;
unsigned long long int a[k],mn=999999999999,mx=0,mn1=0,mx1=0;
for(int i=0;i<k;i++)
{
	int n;
	cin>>n;
	if(n<mn)
	{
		mn=n;
		mn1=1;
	}
	else if(n==mn)
	{
		mn1++;
	}
	if(n>mx)
	{
		mx=n;
		mx1=1;
	}
	else if(n==mx)
	{
		mx1++;
	}
}
if(mn==mx&&k!=2)
{
	cout<<0<<" "<<(mn1*(mx-1))/2;
}
else if(k==2)
{
	cout<<mx-mn<<" "<<1;
}
else
{
	cout<<mx-mn<<" "<<mx1*mn1;
}
}


#include <iostream>
#include<map>
#include <vector>
#include <algorithm>
using namespace std;

int main()
{
 vector <long long >num;
 map <long ,long > maps;
 long long numOfFlowers;
 cin >> numOfFlowers ;
 for(int i =0 ;i <numOfFlowers ;i ++)
 {
     int x;
     cin >> x;
    if(maps.count(x)==0)
    {
        maps[x]=1;
        num.push_back(x);
    }
    else
    {
        maps[x]++;
    }

 }
 sort(num.begin(),num.end());
 long long diff= num[num.size()-1]-num[0];
 long long counter ;
 if(maps[num[0]]==maps[num[num.size()-1]])
 {
     counter = numOfFlowers*(numOfFlowers-1)/2;
 }
 else
 {
   counter = maps[num[num.size()-1]]*maps[num[0]];

 }
 cout <<diff<<" "<<counter<<endl;
    return 0;
}


#include <iostream>
#include<map>
#include <vector>
#include <algorithm>
#include <climits>
using namespace std;

int main()
{
    /*
 vector <long long >num;
 map <long ,long > maps;
 long long numOfFlowers;
 cin >> numOfFlowers ;
 for(int i =0 ;i <numOfFlowers ;i ++)
 {
     int x;
     cin >> x;
    if(maps.count(x)==0)
    {
        maps[x]=1;
        num.push_back(x);
    }
    else
    {
        maps[x]++;
    }

 }
 sort(num.begin(),num.end());

 long long diff= num[num.size()-1]-num[0];
 long long cnt1=0;
 long long cnt2=0;
 for(int i =0  ;i <numOfFlowers;i++)
 {
     if(num[i]==num[0])
     {
         cnt1++;
     }
     else if (num[i]==num[num.size()-1])
     {
         cnt2++;
     }
 }
 cout <<num[0] <<  " " <<num [num.size()-1]<<" "<<cnt1 <<" "<<cnt2<<endl;
 long long counter ;
 if(num[0]==num[num.size()-1])
 {
     counter = numOfFlowers*(numOfFlowers-1)/2;
 }
 else
 {
  // counter = maps[num[num.size()-1]]*maps[num[0]];
counter = cnt1*cnt2;
 }
 cout <<diff<<" "<<counter<<endl;
 */

 vector <long long >num;
 long long numOfFlowers;
 cin >> numOfFlowers ;
 int  minimum =2000000000;
// cout << minimum<<endl;
 int maximum = 0;
 for(int i =0 ;i <numOfFlowers ;i ++)
 {
     int x;
     cin >> x;
     minimum=min(minimum,x);
     maximum=max(maximum,x);
 num.push_back(x);
 }
 sort(num.begin(),num.end());
  long long diff= num[num.size()-1]-num[0];

 long long cnt1=0;
 long long cnt2=0;
 for(int i =0  ;i <numOfFlowers;i++)
 {
     if(num[i]==minimum)
     {
         cnt1++;
     }
     else if (num[i]==maximum)
     {
         cnt2++;
     }
 }
 //cout <<num[0] <<  " " <<num [num.size()-1]<<" "<<cnt1 <<" "<<cnt2<<endl;
 long long counter ;
 cout <<diff<<" ";
 if(minimum==maximum)
 {
     cout <<(numOfFlowers*(numOfFlowers-1))/2<<endl;;
 }
 else
 {
  // counter = maps[num[num.size()-1]]*maps[num[0]];
cout << cnt1*cnt2<<endl;;
 }
    return 0;
}


#include <iostream>
#include<map>
#include <vector>
#include <algorithm>
#include <climits>
using namespace std;

int main()
{
    /*
 vector <long long >num;
 map <long ,long > maps;
 long long numOfFlowers;
 cin >> numOfFlowers ;
 for(int i =0 ;i <numOfFlowers ;i ++)
 {
     int x;
     cin >> x;
    if(maps.count(x)==0)
    {
        maps[x]=1;
        num.push_back(x);
    }
    else
    {
        maps[x]++;
    }

 }
 sort(num.begin(),num.end());

 long long diff= num[num.size()-1]-num[0];
 int cnt1=0;
 int cnt2=0;
 for(int i =0  ;i <numOfFlowers;i++)
 {
     if(num[i]==num[0])
     {
         cnt1++;
     }
     else if (num[i]==num[num.size()-1])
     {
         cnt2++;
     }
 }
 cout <<num[0] <<  " " <<num [num.size()-1]<<" "<<cnt1 <<" "<<cnt2<<endl;
 long long counter ;
 if(num[0]==num[num.size()-1])
 {
     counter = numOfFlowers*(numOfFlowers-1)/2;
 }
 else
 {
  // counter = maps[num[num.size()-1]]*maps[num[0]];
counter = cnt1*cnt2;
 }
 cout <<diff<<" "<<counter<<endl;
 */
 vector <long long >num;
 long long numOfFlowers;
 cin >> numOfFlowers ;
 int  minimum =21000000000;
 cout << minimum<<endl;
 int maximum = 0;
 for(int i =0 ;i <numOfFlowers ;i ++)
 {
     int x;
     cin >> x;
     minimum=min(minimum,x);
     maximum=max(maximum,x);
 num.push_back(x);
 }
 sort(num.begin(),num.end());
  long long diff= num[num.size()-1]-num[0];

 long long cnt1=0;
 long long cnt2=0;
 for(int i =0  ;i <numOfFlowers;i++)
 {
     if(num[i]==minimum)
     {
         cnt1++;
     }
     else if (num[i]==maximum)
     {
         cnt2++;
     }
 }
 //cout <<num[0] <<  " " <<num [num.size()-1]<<" "<<cnt1 <<" "<<cnt2<<endl;
 long long counter ;
 cout <<diff<<" ";
 if(minimum==maximum)
 {
     cout <<(numOfFlowers*(numOfFlowers-1))/2<<endl;;
 }
 else
 {
  // counter = maps[num[num.size()-1]]*maps[num[0]];
cout << cnt1*cnt2<<endl;;
 }
    return 0;
}


#include <iostream>
#include<map>
#include <vector>
#include <algorithm>
using namespace std;

int main()
{
    /*
 vector <long long >num;
 map <long ,long > maps;
 long long numOfFlowers;
 cin >> numOfFlowers ;
 for(int i =0 ;i <numOfFlowers ;i ++)
 {
     int x;
     cin >> x;
    if(maps.count(x)==0)
    {
        maps[x]=1;
        num.push_back(x);
    }
    else
    {
        maps[x]++;
    }

 }
 sort(num.begin(),num.end());

 long long diff= num[num.size()-1]-num[0];
 int cnt1=0;
 int cnt2=0;
 for(int i =0  ;i <numOfFlowers;i++)
 {
     if(num[i]==num[0])
     {
         cnt1++;
     }
     else if (num[i]==num[num.size()-1])
     {
         cnt2++;
     }
 }
 cout <<num[0] <<  " " <<num [num.size()-1]<<" "<<cnt1 <<" "<<cnt2<<endl;
 long long counter ;
 if(num[0]==num[num.size()-1])
 {
     counter = numOfFlowers*(numOfFlowers-1)/2;
 }
 else
 {
  // counter = maps[num[num.size()-1]]*maps[num[0]];
counter = cnt1*cnt2;
 }
 cout <<diff<<" "<<counter<<endl;
 */
 vector <long long >num;
 long long numOfFlowers;
 cin >> numOfFlowers ;
 int  minimum =9000000000;
 int maximum = 0;
 for(int i =0 ;i <numOfFlowers ;i ++)
 {
     int x;
     cin >> x;
     minimum=min(minimum,x);
     maximum=max(maximum,x);
 num.push_back(x);
 }
 sort(num.begin(),num.end());
  long long diff= num[num.size()-1]-num[0];

 long long cnt1=0;
 long long cnt2=0;
 for(int i =0  ;i <numOfFlowers;i++)
 {
     if(num[i]==minimum)
     {
         cnt1++;
     }
     else if (num[i]==maximum)
     {
         cnt2++;
     }
 }
 //cout <<num[0] <<  " " <<num [num.size()-1]<<" "<<cnt1 <<" "<<cnt2<<endl;
 long long counter ;
 cout <<diff<<" ";
 if(minimum==maximum)
 {
     cout << numOfFlowers*(numOfFlowers-1)/2<<endl;;
 }
 else
 {
  // counter = maps[num[num.size()-1]]*maps[num[0]];
cout << cnt1*cnt2<<endl;;
 }
    return 0;
}


#include <iostream>
#include<map>
#include <vector>
#include <algorithm>
using namespace std;

int main()
{
    /*
 vector <long long >num;
 map <long ,long > maps;
 long long numOfFlowers;
 cin >> numOfFlowers ;
 for(int i =0 ;i <numOfFlowers ;i ++)
 {
     int x;
     cin >> x;
    if(maps.count(x)==0)
    {
        maps[x]=1;
        num.push_back(x);
    }
    else
    {
        maps[x]++;
    }

 }
 sort(num.begin(),num.end());

 long long diff= num[num.size()-1]-num[0];
 int cnt1=0;
 int cnt2=0;
 for(int i =0  ;i <numOfFlowers;i++)
 {
     if(num[i]==num[0])
     {
         cnt1++;
     }
     else if (num[i]==num[num.size()-1])
     {
         cnt2++;
     }
 }
 cout <<num[0] <<  " " <<num [num.size()-1]<<" "<<cnt1 <<" "<<cnt2<<endl;
 long long counter ;
 if(num[0]==num[num.size()-1])
 {
     counter = numOfFlowers*(numOfFlowers-1)/2;
 }
 else
 {
  // counter = maps[num[num.size()-1]]*maps[num[0]];
counter = cnt1*cnt2;
 }
 cout <<diff<<" "<<counter<<endl;
 */
 vector <long long >num;
 long long numOfFlowers;
 cin >> numOfFlowers ;
 int  minimum =9000000000;
 int maximum = 0;
 for(int i =0 ;i <numOfFlowers ;i ++)
 {
     int x;
     cin >> x;
     minimum=min(minimum,x);
     maximum=max(maximum,x);
 num.push_back(x);
 }
 sort(num.begin(),num.end());
  long long diff= num[num.size()-1]-num[0];

 long long cnt1=0;
 long long cnt2=0;
 for(int i =0  ;i <numOfFlowers;i++)
 {
     if(num[i]==minimum)
     {
         cnt1++;
     }
     else if (num[i]==maximum)
     {
         cnt2++;
     }
 }
 //cout <<num[0] <<  " " <<num [num.size()-1]<<" "<<cnt1 <<" "<<cnt2<<endl;
 long long counter ;
 if(minimum==maximum)
 {
     counter = numOfFlowers*(numOfFlowers-1)/2;
 }
 else
 {
  // counter = maps[num[num.size()-1]]*maps[num[0]];
counter = cnt1*cnt2;
 }
 cout <<diff<<" "<<counter<<endl;
    return 0;
}


#include <iostream>
#include<map>
#include <vector>
#include <algorithm>
using namespace std;

int main()
{
 vector <int >num;
 map <int ,int > maps;
 int numOfFlowers;
 cin >> numOfFlowers ;
 for(int i =0 ;i <numOfFlowers ;i ++)
 {
     int x;
     cin >> x;
    if(maps.count(x)==0)
    {
        maps[x]=1;
        num.push_back(x);
    }
    else
    {
        maps[x]++;
    }

 }
 sort(num.begin(),num.end());
 long long diff= num[num.size()-1]-num[0];
 long long counter = maps[num[num.size()-1]]*maps[num[0]];
 cout <<diff<<" "<<counter<<endl;
    return 0;
}


#include <iostream>
#include<map>
#include <vector>
#include <algorithm>
using namespace std;

int main()
{
 vector <long long >num;
 map <long ,long > maps;
 long long numOfFlowers;
 cin >> numOfFlowers ;
 for(int i =0 ;i <numOfFlowers ;i ++)
 {
     int x;
     cin >> x;
    if(maps.count(x)==0)
    {
        maps[x]=1;
        num.push_back(x);
    }
    else
    {
        maps[x]++;
    }

 }
 sort(num.begin(),num.end());
 long long diff= num[num.size()-1]-num[0];
 long long counter ;
 if(num[0]==num[num.size()-1])
 {
     counter = numOfFlowers*(numOfFlowers-1)/2;
 }
 else
 {
   counter = maps[num[num.size()-1]]*maps[num[0]];

 }
 cout <<diff<<" "<<counter<<endl;
    return 0;
}


#include <iostream>
#include<map>
#include <vector>
#include <algorithm>
using namespace std;

int main()
{
 vector <int >num;
 map <int ,int > maps;
 int numOfFlowers;
 cin >> numOfFlowers ;
 for(int i =0 ;i <numOfFlowers ;i ++)
 {
     int x;
     cin >> x;
    if(maps.count(x)==0)
    {
        maps[x]=1;
        num.push_back(x);
    }
    else
    {
        maps[x]++;
    }

 }
 sort(num.begin(),num.end());
 long long diff= num[num.size()-1]-num[0];
 long long counter ;
 if(maps[num[0]]==numOfFlowers)
 {
     counter = numOfFlowers*(numOfFlowers-1)/2;
 }
 else
 {
   counter    = maps[num[num.size()-1]]*maps[num[0]];

 }
 cout <<diff<<" "<<counter<<endl;
    return 0;
}


#include <iostream>
#include<map>
#include <vector>
#include <algorithm>
using namespace std;

int main()
{
    /*
 vector <long long >num;
 map <long ,long > maps;
 long long numOfFlowers;
 cin >> numOfFlowers ;
 for(int i =0 ;i <numOfFlowers ;i ++)
 {
     int x;
     cin >> x;
    if(maps.count(x)==0)
    {
        maps[x]=1;
        num.push_back(x);
    }
    else
    {
        maps[x]++;
    }

 }
 sort(num.begin(),num.end());

 long long diff= num[num.size()-1]-num[0];
 int cnt1=0;
 int cnt2=0;
 for(int i =0  ;i <numOfFlowers;i++)
 {
     if(num[i]==num[0])
     {
         cnt1++;
     }
     else if (num[i]==num[num.size()-1])
     {
         cnt2++;
     }
 }
 cout <<num[0] <<  " " <<num [num.size()-1]<<" "<<cnt1 <<" "<<cnt2<<endl;
 long long counter ;
 if(num[0]==num[num.size()-1])
 {
     counter = numOfFlowers*(numOfFlowers-1)/2;
 }
 else
 {
  // counter = maps[num[num.size()-1]]*maps[num[0]];
counter = cnt1*cnt2;
 }
 cout <<diff<<" "<<counter<<endl;
 */
 vector <long long >num;
 long long numOfFlowers;
 cin >> numOfFlowers ;
 int minimum =9000000000;
 int maximum = 0;
 for(int i =0 ;i <numOfFlowers ;i ++)
 {
     int x;
     cin >> x;
     minimum=min(minimum,x);
     maximum=max(maximum,x);
 num.push_back(x);
 }
 sort(num.begin(),num.end());
  long long diff= num[num.size()-1]-num[0];

 int cnt1=0;
 int cnt2=0;
 for(int i =0  ;i <numOfFlowers;i++)
 {
     if(num[i]==minimum)
     {
         cnt1++;
     }
     else if (num[i]==maximum)
     {
         cnt2++;
     }
 }
 //cout <<num[0] <<  " " <<num [num.size()-1]<<" "<<cnt1 <<" "<<cnt2<<endl;
 long long counter ;
 if(minimum==maximum)
 {
     counter = numOfFlowers*(numOfFlowers-1)/2;
 }
 else
 {
  // counter = maps[num[num.size()-1]]*maps[num[0]];
counter = cnt1*cnt2;
 }
 cout <<diff<<" "<<counter<<endl;
    return 0;
}


#include <iostream>
#include<map>
#include <vector>
#include <algorithm>
using namespace std;

int main()
{
 vector <int >num;
 map <int ,int > maps;
 int numOfFlowers;
 cin >> numOfFlowers ;
 for(int i =0 ;i <numOfFlowers ;i ++)
 {
     int x;
     cin >> x;
    if(maps.count(x)==0)
    {
        maps[x]=1;
        num.push_back(x);
    }
    else
    {
        maps[x]++;
    }

 }
 sort(num.begin(),num.end());
 int diff= num[num.size()-1]-num[0];
 int counter = maps[num[num.size()-1]]*maps[num[0]];
 cout <<diff<<" "<<counter<<endl;
    return 0;
}


#include <iostream>
#include<map>
#include <vector>
#include <algorithm>
#include <climits>
using namespace std;

int main()
{
    /*
 vector <long long >num;
 map <long ,long > maps;
 long long numOfFlowers;
 cin >> numOfFlowers ;
 for(int i =0 ;i <numOfFlowers ;i ++)
 {
     int x;
     cin >> x;
    if(maps.count(x)==0)
    {
        maps[x]=1;
        num.push_back(x);
    }
    else
    {
        maps[x]++;
    }

 }
 sort(num.begin(),num.end());

 long long diff= num[num.size()-1]-num[0];
 int cnt1=0;
 int cnt2=0;
 for(int i =0  ;i <numOfFlowers;i++)
 {
     if(num[i]==num[0])
     {
         cnt1++;
     }
     else if (num[i]==num[num.size()-1])
     {
         cnt2++;
     }
 }
 cout <<num[0] <<  " " <<num [num.size()-1]<<" "<<cnt1 <<" "<<cnt2<<endl;
 long long counter ;
 if(num[0]==num[num.size()-1])
 {
     counter = numOfFlowers*(numOfFlowers-1)/2;
 }
 else
 {
  // counter = maps[num[num.size()-1]]*maps[num[0]];
counter = cnt1*cnt2;
 }
 cout <<diff<<" "<<counter<<endl;
 */
 vector <long long >num;
 long long numOfFlowers;
 cin >> numOfFlowers ;
 int  minimum =2000000000;
// cout << minimum<<endl;
 int maximum = 0;
 for(int i =0 ;i <numOfFlowers ;i ++)
 {
     int x;
     cin >> x;
     minimum=min(minimum,x);
     maximum=max(maximum,x);
 num.push_back(x);
 }
 sort(num.begin(),num.end());
  long long diff= num[num.size()-1]-num[0];

 long long cnt1=0;
 long long cnt2=0;
 for(int i =0  ;i <numOfFlowers;i++)
 {
     if(num[i]==minimum)
     {
         cnt1++;
     }
     else if (num[i]==maximum)
     {
         cnt2++;
     }
 }
 //cout <<num[0] <<  " " <<num [num.size()-1]<<" "<<cnt1 <<" "<<cnt2<<endl;
 long long counter ;
 cout <<diff<<" ";
 if(minimum==maximum)
 {
     cout <<(numOfFlowers*(numOfFlowers-1))/2<<endl;;
 }
 else
 {
  // counter = maps[num[num.size()-1]]*maps[num[0]];
cout << cnt1*cnt2<<endl;;
 }
    return 0;
}


#include <iostream>
#include<map>
#include <vector>
#include <algorithm>
using namespace std;

int main()
{
    /*
 vector <long long >num;
 map <long ,long > maps;
 long long numOfFlowers;
 cin >> numOfFlowers ;
 for(int i =0 ;i <numOfFlowers ;i ++)
 {
     int x;
     cin >> x;
    if(maps.count(x)==0)
    {
        maps[x]=1;
        num.push_back(x);
    }
    else
    {
        maps[x]++;
    }

 }
 sort(num.begin(),num.end());

 long long diff= num[num.size()-1]-num[0];
 int cnt1=0;
 int cnt2=0;
 for(int i =0  ;i <numOfFlowers;i++)
 {
     if(num[i]==num[0])
     {
         cnt1++;
     }
     else if (num[i]==num[num.size()-1])
     {
         cnt2++;
     }
 }
 cout <<num[0] <<  " " <<num [num.size()-1]<<" "<<cnt1 <<" "<<cnt2<<endl;
 long long counter ;
 if(num[0]==num[num.size()-1])
 {
     counter = numOfFlowers*(numOfFlowers-1)/2;
 }
 else
 {
  // counter = maps[num[num.size()-1]]*maps[num[0]];
counter = cnt1*cnt2;
 }
 cout <<diff<<" "<<counter<<endl;
 */
 vector <long long >num;
 long long numOfFlowers;
 cin >> numOfFlowers ;
 long  minimum =9000000000;
 long maximum = 0;
 for(int i =0 ;i <numOfFlowers ;i ++)
 {
     int x;
     cin >> x;
     minimum=min(minimum,x);
     maximum=max(maximum,x);
 num.push_back(x);
 }
 sort(num.begin(),num.end());
  long long diff= num[num.size()-1]-num[0];

 long long cnt1=0;
 long long cnt2=0;
 for(int i =0  ;i <numOfFlowers;i++)
 {
     if(num[i]==minimum)
     {
         cnt1++;
     }
     else if (num[i]==maximum)
     {
         cnt2++;
     }
 }
 //cout <<num[0] <<  " " <<num [num.size()-1]<<" "<<cnt1 <<" "<<cnt2<<endl;
 long long counter ;
 if(minimum==maximum)
 {
     counter = numOfFlowers*(numOfFlowers-1)/2;
 }
 else
 {
  // counter = maps[num[num.size()-1]]*maps[num[0]];
counter = cnt1*cnt2;
 }
 cout <<diff<<" "<<counter<<endl;
    return 0;
}


#include <iostream>
#include<map>
#include <vector>
#include <algorithm>
#include <climits>
using namespace std;

int main()
{

 vector <long long >num;
 map <long ,long > maps;
 long long numOfFlowers;
 cin >> numOfFlowers ;
 for(int i =0 ;i <numOfFlowers ;i ++)
 {
     int x;
     cin >> x;
    if(maps.count(x)==0)
    {
        maps[x]=1;
        num.push_back(x);
    }
    else
    {
        maps[x]++;
    }

 }
 sort(num.begin(),num.end());

 long long diff= num[num.size()-1]-num[0];
 long long cnt1=0;
 long long cnt2=0;
 for(int i =0  ;i <numOfFlowers;i++)
 {
     if(num[i]==num[0])
     {
         cnt1++;
     }
     else if (num[i]==num[num.size()-1])
     {
         cnt2++;
     }
 }
// cout <<num[0] <<  " " <<num [num.size()-1]<<" "<<cnt1 <<" "<<cnt2<<endl;
 long long counter ;
 if(num[0]==num[num.size()-1])
 {
     counter = numOfFlowers*(numOfFlowers-1)/2;
 }
 else
 {
  // counter = maps[num[num.size()-1]]*maps[num[0]];
counter = cnt1*cnt2;
 }
 cout <<diff<<" "<<counter<<endl;

 /*
 vector <long long >num;
 long long numOfFlowers;
 cin >> numOfFlowers ;
 int  minimum =2000000000;
// cout << minimum<<endl;
 int maximum = 0;
 for(int i =0 ;i <numOfFlowers ;i ++)
 {
     int x;
     cin >> x;
     minimum=min(minimum,x);
     maximum=max(maximum,x);
 num.push_back(x);
 }
 sort(num.begin(),num.end());
  long long diff= num[num.size()-1]-num[0];

 long long cnt1=0;
 long long cnt2=0;
 for(int i =0  ;i <numOfFlowers;i++)
 {
     if(num[i]==minimum)
     {
         cnt1++;
     }
     else if (num[i]==maximum)
     {
         cnt2++;
     }
 }
 //cout <<num[0] <<  " " <<num [num.size()-1]<<" "<<cnt1 <<" "<<cnt2<<endl;
 long long counter ;
 cout <<diff<<" ";
 if(minimum==maximum)
 {
     cout <<(numOfFlowers*(numOfFlowers-1))/2<<endl;;
 }
 else
 {
  // counter = maps[num[num.size()-1]]*maps[num[0]];
cout << cnt1*cnt2<<endl;;
 }
 */
    return 0;
}


#include <iostream>
#include<map>
#include <vector>
#include <algorithm>
using namespace std;

int main()
{
 vector <long long >num;
 map <long ,long > maps;
 long long numOfFlowers;
 cin >> numOfFlowers ;
 for(int i =0 ;i <numOfFlowers ;i ++)
 {
     int x;
     cin >> x;
    if(maps.count(x)==0)
    {
        maps[x]=1;
        num.push_back(x);
    }
    else
    {
        maps[x]++;
    }

 }
 sort(num.begin(),num.end());

 long long diff= num[num.size()-1]-num[0];
 int cnt1=0;
 int cnt2=0;
 for(int i =0  ;i <numOfFlowers;i++)
 {
     if(num[i]==num[0])
     {
         cnt1++;
     }
     else if (num[i]==num[num.size()-1])
     {
         cnt2++;
     }
 }
 long long counter ;
 if(num[0]==num[num.size()-1])
 {
     counter = numOfFlowers*(numOfFlowers-1)/2;
 }
 else
 {
  // counter = maps[num[num.size()-1]]*maps[num[0]];
counter = cnt1*cnt2;
 }
 cout <<diff<<" "<<counter<<endl;
    return 0;
}


#include <iostream>
#include<map>
#include <vector>
#include <algorithm>
using namespace std;

int main()
{
 vector <long long >num;
 map <long ,long > maps;
 long long numOfFlowers;
 cin >> numOfFlowers ;
 for(int i =0 ;i <numOfFlowers ;i ++)
 {
     int x;
     cin >> x;
    if(maps.count(x)==0)
    {
        maps[x]=1;
        num.push_back(x);
    }
    else
    {
        maps[x]++;
    }

 }
 sort(num.begin(),num.end());
 long long diff= num[num.size()-1]-num[0];
 long long counter ;
 if(maps[num[0]]==numOfFlowers)
 {
     counter = numOfFlowers*(numOfFlowers-1)/2;
 }
 else
 {
   counter    = maps[num[num.size()-1]]*maps[num[0]];

 }
 cout <<diff<<" "<<counter<<endl;
    return 0;
}


#include <iostream>
#include<map>
#include <vector>
#include <algorithm>
using namespace std;

int main()
{
    /*
 vector <long long >num;
 map <long ,long > maps;
 long long numOfFlowers;
 cin >> numOfFlowers ;
 for(int i =0 ;i <numOfFlowers ;i ++)
 {
     int x;
     cin >> x;
    if(maps.count(x)==0)
    {
        maps[x]=1;
        num.push_back(x);
    }
    else
    {
        maps[x]++;
    }

 }
 sort(num.begin(),num.end());

 long long diff= num[num.size()-1]-num[0];
 int cnt1=0;
 int cnt2=0;
 for(int i =0  ;i <numOfFlowers;i++)
 {
     if(num[i]==num[0])
     {
         cnt1++;
     }
     else if (num[i]==num[num.size()-1])
     {
         cnt2++;
     }
 }
 cout <<num[0] <<  " " <<num [num.size()-1]<<" "<<cnt1 <<" "<<cnt2<<endl;
 long long counter ;
 if(num[0]==num[num.size()-1])
 {
     counter = numOfFlowers*(numOfFlowers-1)/2;
 }
 else
 {
  // counter = maps[num[num.size()-1]]*maps[num[0]];
counter = cnt1*cnt2;
 }
 cout <<diff<<" "<<counter<<endl;
 */
 vector <long long >num;
 long long numOfFlowers;
 cin >> numOfFlowers ;
 int  minimum =900000000000;
 int maximum = 0;
 for(int i =0 ;i <numOfFlowers ;i ++)
 {
     int x;
     cin >> x;
     minimum=min(minimum,x);
     maximum=max(maximum,x);
 num.push_back(x);
 }
 sort(num.begin(),num.end());
  long long diff= num[num.size()-1]-num[0];

 long long cnt1=0;
 long long cnt2=0;
 for(int i =0  ;i <numOfFlowers;i++)
 {
     if(num[i]==minimum)
     {
         cnt1++;
     }
     else if (num[i]==maximum)
     {
         cnt2++;
     }
 }
 //cout <<num[0] <<  " " <<num [num.size()-1]<<" "<<cnt1 <<" "<<cnt2<<endl;
 long long counter ;
 cout <<diff<<" ";
 if(minimum==maximum)
 {
     cout <<(numOfFlowers*(numOfFlowers-1))/2<<endl;;
 }
 else
 {
  // counter = maps[num[num.size()-1]]*maps[num[0]];
cout << cnt1*cnt2<<endl;;
 }
    return 0;
}


#include <iostream>
#include<map>
#include <vector>
#include <algorithm>
using namespace std;

int main()
{
    /*
 vector <long long >num;
 map <long ,long > maps;
 long long numOfFlowers;
 cin >> numOfFlowers ;
 for(int i =0 ;i <numOfFlowers ;i ++)
 {
     int x;
     cin >> x;
    if(maps.count(x)==0)
    {
        maps[x]=1;
        num.push_back(x);
    }
    else
    {
        maps[x]++;
    }

 }
 sort(num.begin(),num.end());

 long long diff= num[num.size()-1]-num[0];
 int cnt1=0;
 int cnt2=0;
 for(int i =0  ;i <numOfFlowers;i++)
 {
     if(num[i]==num[0])
     {
         cnt1++;
     }
     else if (num[i]==num[num.size()-1])
     {
         cnt2++;
     }
 }
 cout <<num[0] <<  " " <<num [num.size()-1]<<" "<<cnt1 <<" "<<cnt2<<endl;
 long long counter ;
 if(num[0]==num[num.size()-1])
 {
     counter = numOfFlowers*(numOfFlowers-1)/2;
 }
 else
 {
  // counter = maps[num[num.size()-1]]*maps[num[0]];
counter = cnt1*cnt2;
 }
 cout <<diff<<" "<<counter<<endl;
 */
 vector <long long >num;
 long long numOfFlowers;
 cin >> numOfFlowers ;
 for(int i =0 ;i <numOfFlowers ;i ++)
 {
     int x;
     cin >> x;
 num.push_back(x);
 }
 sort(num.begin(),num.end());
  long long diff= num[num.size()-1]-num[0];

 int minimum = num[0];
 int maximum = num[num.size()-1];
 int cnt1=0;
 int cnt2=0;
 for(int i =0  ;i <numOfFlowers;i++)
 {
     if(num[i]==num[0])
     {
         cnt1++;
     }
     else if (num[i]==num[num.size()-1])
     {
         cnt2++;
     }
 }
 //cout <<num[0] <<  " " <<num [num.size()-1]<<" "<<cnt1 <<" "<<cnt2<<endl;
 long long counter ;
 if(num[0]==num[num.size()-1])
 {
     counter = numOfFlowers*(numOfFlowers-1)/2;
 }
 else
 {
  // counter = maps[num[num.size()-1]]*maps[num[0]];
counter = cnt1*cnt2;
 }
 cout <<diff<<" "<<counter<<endl;
    return 0;
}


#include<iostream>
#include<algorithm>
using namespace::std;
main()
{ int n; cin>>n;
  long long a[n];
  bool found=false;
  for(int i=0;i<n;i++)
  { cin>>a[i];
    if(i>0 && a[i]!=a[i-1]) found=true;
  }
  sort(a,a+n);
  long long p=a[n-1]-a[0];
  cout<<p<<" ";
  long long b=a[n-1],q=a[0],j=0,l=0;
  if(found==true)
   { for(int i=n-1;i>=0;i--)
     { if(a[i]==b)
        j++;
       if(q==a[i])
        l++;
     }
     cout<<l*j;
   }
  else
   { for(int k=n-1;k>0;k--)
       l+=k;
     cout<<l;
   }

}


#include<iostream>
#include<algorithm>
using namespace::std;
main()
{ int n; cin>>n;
  long long a[n]; for(int i=0;i<n;i++) cin>>a[i];
  sort(a,a+n);
  long long p=a[n-1]-a[0],j=0,l=0;
  cout<<p<<" ";
  long long b=a[n-1],q=a[0];
   for(int i=n-1;i>=0;i--)
   { if(a[i]==b && i!=0) j++;
    if(q==a[i] && i!=n-1) l++;
   }
 if(q!=b)
  cout<<l*j;
 else
  cout<<l;
}


#include<iostream>
#include<algorithm>
using namespace::std;
main()
{ int n; cin>>n;
  long long a[n]; for(int i=0;i<n;i++) cin>>a[i];
  sort(a,a+n);
  long long p=a[n-1]-a[0],j=0,l=0;
  cout<<p<<" ";
  int b=a[n-1],q=a[0];
  for(int i=n-1;i>=0;i--)
  { if(a[i]==b && i!=0) j++;
    if(q==a[i] && i!=n-1) l++;
  }
  cout<<l*j;
}


#include<iostream>
#include<algorithm>
using namespace::std;
main()
{ int n; cin>>n;
  long long a[n]; for(int i=0;i<n;i++) cin>>a[i];
  sort(a,a+n);
  long long p=a[n-1]-a[0],j=0,l=0;
  cout<<p<<" ";
  int b=a[n-1],q=a[0];
  for(int i=n-1;i>=0;i--)
  { if(a[i]==b) j++;
    if(q==a[i]) l++;
  }
  cout<<l*j;
}


#include<iostream>
#include<algorithm>
using namespace::std;
main()
{ int n; cin>>n;
  long long a[n]; for(int i=0;i<n;i++) cin>>a[i];
  sort(a,a+n);
  long long p=a[n-1]-a[0];
  long long k=0;
  for(int i=1;i<n-1;i++)
   if(a[0]==a[i] || a[n-1]==a[i])
    k++;
  if(k>0) cout<<p<<" "<<2*k;
  else cout<<p<<" "<<k+1;
}


#include<iostream>
#include<algorithm>
using namespace::std;
main()
{ int n; cin>>n;
  long long a[n];
  bool found=false;
  for(int i=0;i<n;i++)
  { cin>>a[i];
    if(i>0 && a[i]!=a[i-1]) found=true;
  }
  sort(a,a+n);
  long long p=a[n-1]-a[0];
  cout<<p<<" ";
  long long b=a[n-1],q=a[0],j=0,l=0;
  if(found==true)
   { for(int i=n-1;i>=0;i--)
     { if(a[i]==b)
        j++;
       if(q==a[i])
        l++;
     }
     cout<<l*j;
   }
  else
   { for(int k=n-1;k>0;k--)
       l+=k;

     cout<<l;
   }

}


#include<iostream>
#include<algorithm>
using namespace::std;
main()
{ int n; cin>>n;
  long long a[n]; for(int i=0;i<n;i++) cin>>a[i];
  sort(a,a+n);
  long long p=a[n-1]-a[0],j=0,l=0;
  cout<<p<<" ";
  long long b=a[n-1],q=a[0];
   for(int i=n-1;i>=0;i--)
   { if(a[i]==b && i!=0) j++;
    if(q==a[i] && i!=n-1) l++;
   }
 if(q!=b)
  cout<<l*j;
 else
  cout<<l*b;
if(n==200000)
 cout<<endl<<a[n-1];
}


#include<iostream>
#include<algorithm>
using namespace::std;
main()
{ int n; cin>>n;
  long long a[n];
  bool found=false;
  for(int i=0;i<n;i++)
  { cin>>a[i];
    if(i>0 && a[i]==a[i-1]) found=true;
    else found=false;
  }
  sort(a,a+n);
  long long p=a[n-1]-a[0];
  cout<<p<<" ";
  long long b=a[n-1],q=a[0],j=0,l=0;
  if(found==false)
   {for(int i=n-1;i>=0;i--)
    { if(a[i]==b)
       j++;
      if(q==a[i])
       l++;
    }
    cout<<l*j;
   }
  else
   { for(int k=n-1;k>0;k--)
       l+=k;
     cout<<l;
   }

}


#include<iostream>
#include<algorithm>
using namespace::std;
main()
{ int n; cin>>n;
  long long a[n]; for(int i=0;i<n;i++) cin>>a[i];
  sort(a,a+n);
  long long p=a[n-1]-a[0];
  int k=0;
  for(int i=1;i<n-1;i++)
   if(a[0]==a[i] || a[n-1]==a[i])
    k++;
  if(k>0) cout<<p<<" "<<2*k;
  else cout<<p<<" "<<k+1;
}


#include<iostream>
#include<algorithm>
using namespace::std;
main()
{ int n; cin>>n;
  long long a[n]; for(int i=0;i<n;i++) cin>>a[i];
  sort(a,a+n);
  long long p=a[n-1]-a[0],j=0,l=0;
  cout<<p<<" ";
  long long b=a[n-1],q=a[0];
   for(int i=n-1;i>=0;i--)
   { if(a[i]==b && i!=0) j++;
    if(q==a[i] && i!=n-1) l++;
   }
 if(q!=b)
  cout<<l*j;
 else
  cout<<l*b;
}


#include<iostream>
#include<algorithm>
using namespace::std;
main()
{ int n; cin>>n;
  long long a[n]; for(int i=0;i<n;i++) cin>>a[i];
  sort(a,a+n);
  long long p=a[n-1]-a[0];
  cout<<p<<" ";
  int b=a[n-1],q=a[0],j=0,l=0;
  for(int i=n-1;i>=0;i--)
  { if(a[i]==b) j++;
    if(q==a[i]) l++;
  }
  cout<<l*j;
}


#include<iostream>
#include<algorithm>
using namespace::std;
main()
{ int n; cin>>n;
  long long a[n]; for(int i=0;i<n;i++) cin>>a[i];
  sort(a,a+n);
  long long p=a[n-1]-a[0];
  int k=0;
  cout<<p<<" ";
  int b=a[n-1],q=a[0],j=0,l=0;
  for(int i=n-1;i>=0;i--)
  { if(a[i]==b)
     j++;
    if(q==a[i])
     l++;
  }
  cout<<l*j;
}


#include<iostream>
#include<algorithm>
using namespace::std;
main()
{ int n; cin>>n;
  long long a[n]; for(int i=0;i<n;i++) cin>>a[i];
  sort(a,a+n);
  long long p=a[n-1]-a[0],j=0,l=0;
  cout<<p<<" ";
  long long b=a[n-1],q=a[0];
   for(int i=n-1;i>=0;i--)
   { if(a[i]==b && i!=0) j++;
    if(q==a[i] && i!=n-1) l++;
   }
 if(q!=b)
  cout<<l*j;
 else
  cout<<l*b;
if(n==200000 && q==b)
 cout<<endl<<a[n-1];
}


#include<bits/stdc++.h>
using namespace std;
long long a[200045],n,m,k;
/*int maks(int k){
    int maks,jml;
    long long m=1000000000,n=-1000000000;
    for(int i=0;i<k;i++){
        if (a[i]>=n)n=a[i];
        if (a[i]<=m)m=a[i];

    }
    return abs(m-n);
}*/
int main(){

   long long w=0,q=0;
    cin>>n;
m=1000000000,k=0;
    for(int i=0;i<n;i++){
        cin>>a[i];
        if (a[i]<= m)m = a[i];
        if (a[i]>=k) k=a[i];
    }
    //cout<<m<<k<<endl;
    sort(a,a+n);
   // if (m!=k){
        for(int i=0;i<n;i++){
            if(a[i]==m) q++;
            if(a[i]==k) w++;}
     //       }
   // cout<<q<<w<<endl;
    long long lop=(n-1)*(n/2);

    if(n%2==1 && m==k)cout<<0<<" "<<n/2+lop<<endl; else
    if(m==k)cout<<abs(m-k)<<" "<<lop<<endl;else
    cout<<abs(m-k)<<" "<<q*w<<endl;
   //int q=maks(n);

/*
    for(int i=0;i<n;i++){
        for(int y=i+1;y<n;y++)
        if (abs(a[i]-a[y])==q) w++;
    }
    cout<<q<<" "<<w<<endl;*/
}


using System;
using System.Collections.Generic;
using System.IO;

namespace codeforces
{
    class Solver
    {
        public void SolveTask()
        {
            Dictionary<long, long> left = new Dictionary<long, long>();
            Dictionary<long, long> right = new Dictionary<long, long>();

            int n;
            long k, x, ans = 0;

            var s = Console.ReadLine().Split(' ');
            n = int.Parse(s[0]);
            k = long.Parse(s[1]);
            s = Console.ReadLine().Split(' ');
            long[] array = new long[n];
            for (int i = 0; i < n; i++)
            {
                x = long.Parse(s[i]);
                array[i] = x;
                if (!right.ContainsKey(x))
                    right.Add(x, 1);
                else
                    right[x]++;
            }

            for (int i = 0; i < n; i++)
            {
                x = array[i];
                right[x]--;
                if (x % k == 0)
                {
                    if (left.ContainsKey(x / k) && right.ContainsKey(x * k))
                    {
                        ans += left[x / k] * right[x * k];
                    }
                }
                if (!left.ContainsKey(x))
                    left.Add(x, 1);
                else
                    left[x]++;
            }

            Console.WriteLine(ans);
        }
    }

    class Third
    {
        static void Main()
        {
            Solver solver = new Solver();
            solver.SolveTask();
        }
    }
}


using System;
using System.Collections.Generic;

namespace codeforces
{
    internal class Solver
    {
        internal void SolveTask()
        {
            Dictionary<long, int> left = new Dictionary<long, int>();
            Dictionary<long, int> right = new Dictionary<long, int>();

            int n;
            long k, x, ans = 0;

            var s = Console.ReadLine().Split(' ');
            n = int.Parse(s[0]);
            k = long.Parse(s[1]);
            s = Console.ReadLine().Split(' ');
            long[] array = new long[n];
            for (int i = 0; i < n; i++)
            {
                x = long.Parse(s[i]);
                array[i] = x;
                if (!right.ContainsKey(x))
                    right.Add(x, 1);
                else
                    right[x]++;
            }

            for (int i = 0; i < n; i++)
            {
                x = array[i];
                right[x]--;
                if (x % k == 0)
                {
                    if (left.ContainsKey(x / k) && right.ContainsKey(x * k))
                    {
                        ans += left[x / k] * right[x * k];
                    }
                }
                if (!left.ContainsKey(x))
                    left.Add(x, 1);
                else
                    left[x]++;
            }

            Console.WriteLine(ans);
        }
    }

    class Third
    {
        static void Main(string[] args)
        {
            Solver solver = new Solver();
            solver.SolveTask();
        }
    }
}


/*
 * temp.cpp
 *
 *  Created on: 2012-7-18
 *      Author: BSBandme
 */
#include <iostream>
#include <fstream>
#include <string.h>
#include <cstdio>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <cassert>
#include <iomanip>
#include <deque>
#include <utility>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <climits>
#include <cctype>
#include <cmath>
#include <cstdlib>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef vector <int> vi;
typedef vector <ll> vl;
typedef vector <double> vd;

const double pi = acos(0.0) * 2.0;
const double eps = 1e-12;

template <class T> inline T abs1(T a) {return a < 0 ? -a : a;}
template <class T> inline T max1(T a, T b) {return a > b ? a : b;}
template <class T> inline T min1(T a, T b) {return a < b ? a : b;}
template <class T> inline T gcd1(T a, T b) {
	if(a < b) swap(a, b);
	if(a % b == 0) return b;
	return gcd1(b, a % b);
}
template <class T> inline T lb(T num) {return num & (-num); }
inline int bitnum(ll nValue){
    nValue = ((0xaaaaaaaaaaaaaaaall & nValue)>>1) + (0x5555555555555555ll & nValue);
    nValue = ((0xccccccccccccccccll & nValue)>>2) + (0x3333333333333333ll & nValue);
    nValue = ((0xf0f0f0f0f0f0f0f0ll & nValue)>>4) + (0x0f0f0f0f0f0f0f0fll & nValue);
    nValue = ((0xff00ff00ff00ff00ll & nValue)>>8) + (0x00ff00ff00ff00ffll & nValue);
    nValue = ((0xffff0000ffff0000ll & nValue)>>16) + (0x0000ffff0000ffffll & nValue);
    nValue = ((0xffffffff00000000ll & nValue)>>32) + (0x00000000ffffffffll & nValue);
	return nValue;
}
inline int jud(double a, double b){
	if(abs1(a - b) < eps) return 0;
	if(a < b) return -1;
	return 1;
}
long long pow(long long n, long long m, long long mod = 0){
	long long ans = 1;
	long long k = n;
	while(m){
		if(m & 1) {
			ans *= k;
			if(mod) ans %= mod;
		}
		k *= k;
		if(mod) k %= mod;
		m >>= 1;
	}
	return ans;
}

ull x1, x2, yy, y2;
const ull mod = 100000000000ull;

inline ull sumsqr(ull n){
	ull ans = ((((n * (n + 1)) % mod) / 2ull * (2ull * n + 1ull)) % mod);
	if(ans % 3 == 0) return ans / 3;
	if((ans + mod) % 3 == 0) return (ans + mod) / 3;
	return (ans + mod * 2) / 3;
}
inline ull count(ull x, ull y){
	if(x == y){
		x++, y++;
		return ((((x * y) % mod) * (((x * y + 1) % mod))) % mod) / 2;
	}
	ull ans = min1(x, y) + 1;
	ans = ((((ans * ans) % mod) * (((ans * ans + 1) % mod))) % mod) / 2;
	ans %= mod;
	if(y < x){
		ull x1 = sumsqr(min1(x, y));
		ull x2 = sumsqr(max1(x, y));
		if(x1 > x2) x2 += mod;
		ull a = x2 - x1;
		ull c = max1(x, y) - min1(x, y);
		ull xiang = min1(x, y) + 1;
		ans += (((xiang * (xiang + 1)) % mod) / 2 * c) % mod;
		ans += (a * xiang) % mod;
	}else {
		ull x1 = sumsqr(min1(x, y) + 1);
		ull x2 = sumsqr(max1(x, y) + 1);
		if(x1 > x2) x2 += mod;
		ull a = x2 - x1;
		ull c = max1(x, y) - min1(x, y);
		ull xiang = min1(x, y);
		ans += (a * (xiang + 1)) % mod;
		ull ans1 = (((xiang * (xiang + 1)) % mod) / 2 * c) % mod;
		if(ans < ans1) ans += mod;
		ans -= ans1;
	}
	return ans % mod;
}
inline double dsumsqr(double n){
	double ans = n * (n + 1) * (2 * n + 1) / 6;
	return ans;
}
inline double dcount(ull x, ull y){
	if(x == y){
		x++, y++;
		return double(x * y) * double(x * y + 1) / 2;
	}
	double ans = min1(x, y) + 1;
	ans = (ans * ans) * (ans * ans + 1) / 2;
	if(y < x){
		double x1 = dsumsqr(min1(x, y));
		double x2 = dsumsqr(max1(x, y));
		double a = x2 - x1;
		double c = max1(x, y) - min1(x, y);
		double xiang = min1(x, y) + 1;
		ans += (xiang * (xiang + 1)) / 2 * c;
		ans += a * xiang;
	}else {
		double x1 = sumsqr(min1(x, y) + 1);
		double x2 = sumsqr(max1(x, y) + 1);
		double a = x2 - x1;
		double c = max1(x, y) - min1(x, y);
		double xiang = min1(x, y);
		ans += a * (xiang + 1);
		double ans1 = (xiang * (xiang + 1)) / 2 * c;
		ans -= ans1;
	}
	return ans;
}
int main(){
//	freopen("input.txt","r", stdin);
//	ifstream cin("input.txt");
	int n;
	scanf("%d", &n);
	for(int i = 0; i < n; i++){
		scanf("%I64u%I64u%I64u%I64u", &x1, &yy, &x2, &y2);
		x1--; yy--; x2--; y2--;
		swap(x1, yy); swap(x2, y2);
		ull ans = count(x2, y2);
		double dans = dcount(x2, y2);
		if(x1 > 0 && yy > 0){
			ans += count(x1 - 1, yy - 1);
			dans += dcount(x1 - 1, yy - 1);
		}
		ans += mod;
		if(x1 > 0){
			ans -= count (x1 - 1, y2);
			dans -= dcount(x1 - 1, y2);
		}
		ans += mod;
		if(yy > 0){
			ans -= count (x2, yy - 1);
			dans -= dcount(x2, yy - 1);
		}
		ans %= mod;
		if(dans > mod){
			printf("...");
			ull ans1 = ans;
			int i = 0;
			for(; ans > 0; i++) ans /= 10;
			for(int j = i; j < 10; j++) printf("0");
			printf("%I64u\n", ans1);
		} else printf("%I64u\n", ans);
	}

	return 0;
}


/*
 * temp.cpp
 *
 *  Created on: 2012-7-18
 *      Author: BSBandme
 */
#include <iostream>
#include <fstream>
#include <string.h>
#include <cstdio>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <cassert>
#include <iomanip>
#include <deque>
#include <utility>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <climits>
#include <cctype>
#include <cmath>
#include <cstdlib>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef vector <int> vi;
typedef vector <ll> vl;
typedef vector <double> vd;

const double pi = acos(0.0) * 2.0;
const double eps = 1e-12;

template <class T> inline T abs1(T a) {return a < 0 ? -a : a;}
template <class T> inline T max1(T a, T b) {return a > b ? a : b;}
template <class T> inline T min1(T a, T b) {return a < b ? a : b;}
template <class T> inline T gcd1(T a, T b) {
	if(a < b) swap(a, b);
	if(a % b == 0) return b;
	return gcd1(b, a % b);
}
template <class T> inline T lb(T num) {return num & (-num); }
inline int bitnum(ll nValue){
    nValue = ((0xaaaaaaaaaaaaaaaall & nValue)>>1) + (0x5555555555555555ll & nValue);
    nValue = ((0xccccccccccccccccll & nValue)>>2) + (0x3333333333333333ll & nValue);
    nValue = ((0xf0f0f0f0f0f0f0f0ll & nValue)>>4) + (0x0f0f0f0f0f0f0f0fll & nValue);
    nValue = ((0xff00ff00ff00ff00ll & nValue)>>8) + (0x00ff00ff00ff00ffll & nValue);
    nValue = ((0xffff0000ffff0000ll & nValue)>>16) + (0x0000ffff0000ffffll & nValue);
    nValue = ((0xffffffff00000000ll & nValue)>>32) + (0x00000000ffffffffll & nValue);
	return nValue;
}
inline int jud(double a, double b){
	if(abs1(a - b) < eps) return 0;
	if(a < b) return -1;
	return 1;
}
long long pow(long long n, long long m, long long mod = 0){
	long long ans = 1;
	long long k = n;
	while(m){
		if(m & 1) {
			ans *= k;
			if(mod) ans %= mod;
		}
		k *= k;
		if(mod) k %= mod;
		m >>= 1;
	}
	return ans;
}

ull x1, x2, yy, y2;
const ull mod = 1000000000000ull;

inline ull sumsqr(ull n){
	ull ans = ((((n * (n + 1)) % mod) / 2ull * (2ull * n + 1ull)) % mod);
	if(ans % 3 == 0) return ans / 3;
	if((ans + mod) % 3 == 0) return (ans + mod) / 3;
	return (ans + mod * 2) / 3;
}
inline ull count(ull x, ull y){
	if(x == y){
		x++, y++;
		return ((((x * y) % mod) * (((x * y + 1) % mod))) % mod) / 2;
	}
	ull ans = min1(x, y) + 1;
	ans = ((((ans * ans) % mod) * (((ans * ans + 1) % mod))) % mod) / 2;
	ans %= mod;
	if(y < x){
		ull x1 = sumsqr(min1(x, y));
		ull x2 = sumsqr(max1(x, y));
		if(x1 > x2) x2 += mod;
		ull a = x2 - x1;
		ull c = max1(x, y) - min1(x, y);
		ull xiang = min1(x, y) + 1;
		ans += (((xiang * (xiang + 1)) % mod) / 2 * c) % mod;
		ans += (a * xiang) % mod;
	}else {
		ull x1 = sumsqr(min1(x, y) + 1);
		ull x2 = sumsqr(max1(x, y) + 1);
		if(x1 > x2) x2 += mod;
		ull a = x2 - x1;
		ull c = max1(x, y) - min1(x, y);
		ull xiang = min1(x, y);
		ans += (a * (xiang + 1)) % mod;
		ull ans1 = (((xiang * (xiang + 1)) % mod) / 2 * c) % mod;
		if(ans < ans1) ans += mod;
		ans -= ans1;
	}
	return ans % mod;
}
inline double dsumsqr(double n){
	double ans = n * (n + 1) * (2 * n + 1) / 6;
	return ans;
}
inline double dcount(ull x, ull y){
	if(x == y){
		x++, y++;
		return double(x * y) * double(x * y + 1) / 2;
	}
	double ans = min1(x, y) + 1;
	ans = (ans * ans) * (ans * ans + 1) / 2;
	if(y < x){
		double x1 = dsumsqr(min1(x, y));
		double x2 = dsumsqr(max1(x, y));
		double a = x2 - x1;
		double c = max1(x, y) - min1(x, y);
		double xiang = min1(x, y) + 1;
		ans += (xiang * (xiang + 1)) / 2 * c;
		ans += a * xiang;
	}else {
		double x1 = sumsqr(min1(x, y) + 1);
		double x2 = sumsqr(max1(x, y) + 1);
		double a = x2 - x1;
		double c = max1(x, y) - min1(x, y);
		double xiang = min1(x, y);
		ans += a * (xiang + 1);
		double ans1 = (xiang * (xiang + 1)) / 2 * c;
		ans -= ans1;
	}
	return ans;
}
int main(){
//	freopen("input.txt","r", stdin);
//	ifstream cin("input.txt");
	int n;
	scanf("%d", &n);
	for(int i = 0; i < n; i++){
		scanf("%I64u%I64u%I64u%I64u", &x1, &yy, &x2, &y2);
		x1--; yy--; x2--; y2--;
		swap(x1, yy); swap(x2, y2);
		ull ans = count(x2, y2);
		double dans = dcount(x2, y2);
		if(x1 > 0 && yy > 0){
			ans += count(x1 - 1, yy - 1);
			dans += dcount(x1 - 1, yy - 1);
		}
		ans += mod;
		if(x1 > 0){
			ans -= count (x1 - 1, y2);
			dans -= dcount(x1 - 1, y2);
		}
		ans += mod;
		if(yy > 0){
			ans -= count (x2, yy - 1);
			dans -= dcount(x2, yy - 1);
		}
		ans %= mod;
		if(dans > mod / 100){
			printf("...");
			ans = ans % (mod / 100);
			ull ans1 = ans;
			int i = 0;
			for(; ans > 0; i++) ans /= 10;
			for(int j = i; j < 10; j++) printf("0");
			printf("%I64u\n", ans1);
		} else printf("%I64u\n", ans % (mod / 100));
	}

	return 0;
}


/*
 * temp.cpp
 *
 *  Created on: 2012-7-18
 *      Author: BSBandme
 */
#include <iostream>
#include <fstream>
#include <string.h>
#include <cstdio>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <cassert>
#include <iomanip>
#include <deque>
#include <utility>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <climits>
#include <cctype>
#include <cmath>
#include <cstdlib>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef vector <int> vi;
typedef vector <ll> vl;
typedef vector <double> vd;

const double pi = acos(0.0) * 2.0;
const double eps = 1e-12;

template <class T> inline T abs1(T a) {return a < 0 ? -a : a;}
template <class T> inline T max1(T a, T b) {return a > b ? a : b;}
template <class T> inline T min1(T a, T b) {return a < b ? a : b;}
template <class T> inline T gcd1(T a, T b) {
	if(a < b) swap(a, b);
	if(a % b == 0) return b;
	return gcd1(b, a % b);
}
template <class T> inline T lb(T num) {return num & (-num); }
inline int bitnum(ll nValue){
    nValue = ((0xaaaaaaaaaaaaaaaall & nValue)>>1) + (0x5555555555555555ll & nValue);
    nValue = ((0xccccccccccccccccll & nValue)>>2) + (0x3333333333333333ll & nValue);
    nValue = ((0xf0f0f0f0f0f0f0f0ll & nValue)>>4) + (0x0f0f0f0f0f0f0f0fll & nValue);
    nValue = ((0xff00ff00ff00ff00ll & nValue)>>8) + (0x00ff00ff00ff00ffll & nValue);
    nValue = ((0xffff0000ffff0000ll & nValue)>>16) + (0x0000ffff0000ffffll & nValue);
    nValue = ((0xffffffff00000000ll & nValue)>>32) + (0x00000000ffffffffll & nValue);
	return nValue;
}
inline int jud(double a, double b){
	if(abs1(a - b) < eps) return 0;
	if(a < b) return -1;
	return 1;
}
long long pow(long long n, long long m, long long mod = 0){
	long long ans = 1;
	long long k = n;
	while(m){
		if(m & 1) {
			ans *= k;
			if(mod) ans %= mod;
		}
		k *= k;
		if(mod) k %= mod;
		m >>= 1;
	}
	return ans;
}

ull x1, x2, yy, y2;
const ull mmod = 10000000000ull;
inline ull multi(ull x, ull y, ull mod){
	ull ans = 0;
	ull x1 = x % 100000, x2 = x / 100000;
	ans += x1 * y;
	ans += (x2 * y) % (mod / 100000) * 100000;
	ans %= mod;
	return ans;
}

inline ull sumsqr(ull n, ull mod){
	ull ans = multi((((n * (n + 1)) / 2ull) % mod), ((2ull * n + 1ull) % mod), mod);
	if(ans % 3 == 0) return ans / 3;
	if((ans + mod) % 3 == 0) return (ans + mod) / 3;
	return (ans + mod * 2) / 3;
}
inline ull count1(ull x, ull y, ull mod){
	if(x == y){
		x++, y++;
		if(x & 1) return multi(((x * y + 1) / 2) % mod, (x * y) % mod, mod);
		return multi((x * y + 1) % mod, (x * y / 2) % mod, mod);
	}
	ull ans = min1(x, y) + 1;
	if(ans & 1) ans = multi(((ans * ans + 1) / 2) % mod, (ans * ans) % mod, mod);
	else ans = multi((ans * ans / 2) % mod, (ans * ans + 1) % mod, mod);
	ans %= mod;
	if(y < x){
		ull x1 = sumsqr(min1(x, y), mod);
		ull x2 = sumsqr(max1(x, y), mod);
		if(x1 > x2) x2 += mod;
		ull a = x2 - x1;
		ull c = max1(x, y) - min1(x, y);
		ull xiang = min1(x, y) + 1;
		ans += ((((xiang * (xiang + 1)) / 2ull) % mod) * c) % mod;
		ans += (a * xiang) % mod;
	}else {
		ull x1 = sumsqr(min1(x, y) + 1, mod);
		ull x2 = sumsqr(max1(x, y) + 1, mod);
		if(x1 > x2) x2 += mod;
		ull a = x2 - x1;
		ull c = max1(x, y) - min1(x, y);
		ull xiang = min1(x, y);
		ans += (a * (xiang + 1)) % mod;
		ull ans1 = ((((xiang * (xiang + 1)) / 2) % mod) * c) % mod;
		if(ans < ans1) ans += mod;
		ans -= ans1;
	}
	return ans % mod;
}
inline double dsumsqr(double n){
	double ans = n * (n + 1) * (2 * n + 1) / 6;
	return ans;
}
inline double dcount1(ull x, ull y){
	if(x == y){
		x++, y++;
		return double(x * y) * double(x * y + 1) / 2;
	}
	double ans = min1(x, y) + 1;
	ans = (ans * ans) * (ans * ans + 1) / 2;
	if(y < x){
		double x1 = dsumsqr(min1(x, y));
		double x2 = dsumsqr(max1(x, y));
		double a = x2 - x1;
		double c = max1(x, y) - min1(x, y);
		double xiang = min1(x, y) + 1;
		ans += (xiang * (xiang + 1)) / 2 * c;
		ans += a * xiang;
	}else {
		double x1 = dsumsqr(min1(x, y) + 1);
		double x2 = dsumsqr(max1(x, y) + 1);
		double a = x2 - x1;
		double c = max1(x, y) - min1(x, y);
		double xiang = min1(x, y);
		ans += a * (xiang + 1);
		double ans1 = (xiang * (xiang + 1)) / 2 * c;
		ans -= ans1;
	}
	return ans;
}
int main(){
//	freopen("input.txt","r", stdin);
//	ifstream cin("input.txt");
	int n;
	scanf("%d", &n);
	ull rem;
	for(int i = 0; i < n; i++){
		scanf("%I64u%I64u%I64u%I64u", &x1, &yy, &x2, &y2);
		if(i == 0) rem = x1;
//		if((n == 100000) && i == 20878 && rem == 999990710) printf("%I64u %I64u %I64u %I64u\n", x1, yy, x2, y2);
		x1--; yy--; x2--; y2--;
		swap(x1, yy); swap(x2, y2);
		ull ans = count1(x2, y2, mmod);
		double dans = dcount1(x2, y2);
		ull mmod1 = mmod * 2 + 138923478;
		ull ansr = count1(x2, y2, mmod1);
		if(x1 > 0 && yy > 0){
			ans += count1(x1 - 1, yy - 1, mmod);
			ansr += count1(x1 - 1, yy - 1, mmod1);
			dans += dcount1(x1 - 1, yy - 1);
		}
		ans += mmod;
		ansr += mmod1;
		if(x1 > 0){
			ans -= count1 (x1 - 1, y2, mmod);
			ansr -= count1 (x1 - 1, y2, mmod1);
			dans -= dcount1(x1 - 1, y2);
		}
		ans += mmod;
		ansr += mmod1;
		if(yy > 0){
			ans -= count1 (x2, yy - 1, mmod);
			ansr -= count1 (x2, yy - 1, mmod1);
			dans -= dcount1(x2, yy - 1);
		}
		ans %= mmod;
		ansr %= mmod1;
		if(dans > mmod || ansr != ans){
			printf("...");
			ans = ans % (mmod);
			ull ans1 = ans;
			int i = 0;
			for(; ans > 0; i++) ans /= 10;
			for(int j = i; j < 10; j++) printf("0");
			printf("%I64u\n", ans1);
		} else printf("%I64u\n", ans %mmod);
	}

	return 0;
}


/*
 * temp.cpp
 *
 *  Created on: 2012-7-18
 *      Author: BSBandme
 */
#include <iostream>
#include <fstream>
#include <string.h>
#include <cstdio>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <cassert>
#include <iomanip>
#include <deque>
#include <utility>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <climits>
#include <cctype>
#include <cmath>
#include <cstdlib>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef vector <int> vi;
typedef vector <ll> vl;
typedef vector <double> vd;

const double pi = acos(0.0) * 2.0;
const double eps = 1e-12;

template <class T> inline T abs1(T a) {return a < 0 ? -a : a;}
template <class T> inline T max1(T a, T b) {return a > b ? a : b;}
template <class T> inline T min1(T a, T b) {return a < b ? a : b;}
template <class T> inline T gcd1(T a, T b) {
	if(a < b) swap(a, b);
	if(a % b == 0) return b;
	return gcd1(b, a % b);
}
template <class T> inline T lb(T num) {return num & (-num); }
inline int bitnum(ll nValue){
    nValue = ((0xaaaaaaaaaaaaaaaall & nValue)>>1) + (0x5555555555555555ll & nValue);
    nValue = ((0xccccccccccccccccll & nValue)>>2) + (0x3333333333333333ll & nValue);
    nValue = ((0xf0f0f0f0f0f0f0f0ll & nValue)>>4) + (0x0f0f0f0f0f0f0f0fll & nValue);
    nValue = ((0xff00ff00ff00ff00ll & nValue)>>8) + (0x00ff00ff00ff00ffll & nValue);
    nValue = ((0xffff0000ffff0000ll & nValue)>>16) + (0x0000ffff0000ffffll & nValue);
    nValue = ((0xffffffff00000000ll & nValue)>>32) + (0x00000000ffffffffll & nValue);
	return nValue;
}
inline int jud(double a, double b){
	if(abs1(a - b) < eps) return 0;
	if(a < b) return -1;
	return 1;
}
long long pow(long long n, long long m, long long mod = 0){
	long long ans = 1;
	long long k = n;
	while(m){
		if(m & 1) {
			ans *= k;
			if(mod) ans %= mod;
		}
		k *= k;
		if(mod) k %= mod;
		m >>= 1;
	}
	return ans;
}

ull x1, x2, yy, y2;
const ull mod = 10000000000ull;

inline ull sumsqr(ull n){
	ull ans = (((((n * (n + 1)) / 2ull) % mod)  * (2ull * n + 1ull)) % mod);
	if(ans % 3 == 0) return ans / 3;
	if((ans + mod) % 3 == 0) return (ans + mod) / 3;
	return (ans + mod * 2) / 3;
}
inline ull multi(ull x, ull y){
	ull ans = 0;
	ull x1 = x % 100000, x2 = x / 100000;
	ans += x1 * y;
	ans += (x2 * y) % (mod / 100000) * 100000;
	ans %= mod;
	return ans;
}
inline ull count(ull x, ull y){
	if(x == y){
		x++, y++;
		if(x & 1) return multi((x * y + 1) / 2, x * y);
		return multi((x * y + 1), x * y / 2);
	}
	ull ans = min1(x, y) + 1;
	if(ans & 1) ans = multi((ans * ans + 1) / 2, ans * ans);
	else ans = multi(ans * ans / 2, ans * ans + 1);
	ans %= mod;
	if(y < x){
		ull x1 = sumsqr(min1(x, y));
		ull x2 = sumsqr(max1(x, y));
		if(x1 > x2) x2 += mod;
		ull a = x2 - x1;
		ull c = max1(x, y) - min1(x, y);
		ull xiang = min1(x, y) + 1;
		ans += ((((xiang * (xiang + 1)) / 2ull) % mod) * c) % mod;
		ans += (a * xiang) % mod;
	}else {
		ull x1 = sumsqr(min1(x, y) + 1);
		ull x2 = sumsqr(max1(x, y) + 1);
		if(x1 > x2) x2 += mod;
		ull a = x2 - x1;
		ull c = max1(x, y) - min1(x, y);
		ull xiang = min1(x, y);
		ans += (a * (xiang + 1)) % mod;
		ull ans1 = ((((xiang * (xiang + 1)) / 2) % mod) * c) % mod;
		if(ans < ans1) ans += mod;
		ans -= ans1;
	}
	return ans % mod;
}
inline double dsumsqr(double n){
	double ans = n * (n + 1) * (2 * n + 1) / 6;
	return ans;
}
inline double dcount(ull x, ull y){
	if(x == y){
		x++, y++;
		return double(x * y) * double(x * y + 1) / 2;
	}
	double ans = min1(x, y) + 1;
	ans = (ans * ans) * (ans * ans + 1) / 2;
	if(y < x){
		double x1 = dsumsqr(min1(x, y));
		double x2 = dsumsqr(max1(x, y));
		double a = x2 - x1;
		double c = max1(x, y) - min1(x, y);
		double xiang = min1(x, y) + 1;
		ans += (xiang * (xiang + 1)) / 2 * c;
		ans += a * xiang;
	}else {
		double x1 = sumsqr(min1(x, y) + 1);
		double x2 = sumsqr(max1(x, y) + 1);
		double a = x2 - x1;
		double c = max1(x, y) - min1(x, y);
		double xiang = min1(x, y);
		ans += a * (xiang + 1);
		double ans1 = (xiang * (xiang + 1)) / 2 * c;
		ans -= ans1;
	}
	return ans;
}
int main(){
//	freopen("input.txt","r", stdin);
//	ifstream cin("input.txt");
	int n;
	scanf("%d", &n);
	for(int i = 0; i < n; i++){
		scanf("%I64u%I64u%I64u%I64u", &x1, &yy, &x2, &y2);
		if((n == 100) && i == 15)printf("%I64u %I64u %I64u %I64u\n", x1, yy, x2, y2);
		x1--; yy--; x2--; y2--;
		swap(x1, yy); swap(x2, y2);
		ull ans = count(x2, y2);
		double dans = dcount(x2, y2);
		if(x1 > 0 && yy > 0){
			ans += count(x1 - 1, yy - 1);
			dans += dcount(x1 - 1, yy - 1);
		}
		ans += mod;
		if(x1 > 0){
			ans -= count (x1 - 1, y2);
			dans -= dcount(x1 - 1, y2);
		}
		ans += mod;
		if(yy > 0){
			ans -= count (x2, yy - 1);
			dans -= dcount(x2, yy - 1);
		}
		ans %= mod;
		if(dans > mod){
			printf("...");
			ans = ans % (mod);
			ull ans1 = ans;
			int i = 0;
			for(; ans > 0; i++) ans /= 10;
			for(int j = i; j < 10; j++) printf("0");
			printf("%I64u\n", ans1);
		} else printf("%I64u\n", ans %mod);
	}

	return 0;
}


/*
 * temp.cpp
 *
 *  Created on: 2012-7-18
 *      Author: BSBandme
 */
#include <iostream>
#include <fstream>
#include <string.h>
#include <cstdio>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <cassert>
#include <iomanip>
#include <deque>
#include <utility>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <climits>
#include <cctype>
#include <cmath>
#include <cstdlib>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef vector <int> vi;
typedef vector <ll> vl;
typedef vector <double> vd;

const double pi = acos(0.0) * 2.0;
const double eps = 1e-12;

template <class T> inline T abs1(T a) {return a < 0 ? -a : a;}
template <class T> inline T max1(T a, T b) {return a > b ? a : b;}
template <class T> inline T min1(T a, T b) {return a < b ? a : b;}
template <class T> inline T gcd1(T a, T b) {
	if(a < b) swap(a, b);
	if(a % b == 0) return b;
	return gcd1(b, a % b);
}
template <class T> inline T lb(T num) {return num & (-num); }
inline int bitnum(ll nValue){
    nValue = ((0xaaaaaaaaaaaaaaaall & nValue)>>1) + (0x5555555555555555ll & nValue);
    nValue = ((0xccccccccccccccccll & nValue)>>2) + (0x3333333333333333ll & nValue);
    nValue = ((0xf0f0f0f0f0f0f0f0ll & nValue)>>4) + (0x0f0f0f0f0f0f0f0fll & nValue);
    nValue = ((0xff00ff00ff00ff00ll & nValue)>>8) + (0x00ff00ff00ff00ffll & nValue);
    nValue = ((0xffff0000ffff0000ll & nValue)>>16) + (0x0000ffff0000ffffll & nValue);
    nValue = ((0xffffffff00000000ll & nValue)>>32) + (0x00000000ffffffffll & nValue);
	return nValue;
}
inline int jud(double a, double b){
	if(abs1(a - b) < eps) return 0;
	if(a < b) return -1;
	return 1;
}
long long pow(long long n, long long m, long long mod = 0){
	long long ans = 1;
	long long k = n;
	while(m){
		if(m & 1) {
			ans *= k;
			if(mod) ans %= mod;
		}
		k *= k;
		if(mod) k %= mod;
		m >>= 1;
	}
	return ans;
}

ull x1, x2, yy, y2;
const ull mod = 10000000000ull;

inline ull sumsqr(ull n){
	ull ans = ((((n * (n + 1)) % mod) / 2ull * (2ull * n + 1ull)) % mod);
	if(ans % 3 == 0) return ans / 3;
	if((ans + mod) % 3 == 0) return (ans + mod) / 3;
	return (ans + mod * 2) / 3;
}
inline ull count(ull x, ull y){
	if(x == y){
		x++, y++;
		return ((((x * y) % mod) * (((x * y + 1) % mod))) % mod) / 2;
	}
	ull ans = min1(x, y) + 1;
	ans = ((((ans * ans) % mod) * (((ans * ans + 1) % mod))) % mod) / 2;
	ans %= mod;
	if(y < x){
		ull x1 = sumsqr(min1(x, y));
		ull x2 = sumsqr(max1(x, y));
		if(x1 > x2) x2 += mod;
		ull a = x2 - x1;
		ull c = max1(x, y) - min1(x, y);
		ull xiang = min1(x, y) + 1;
		ans += (((xiang * (xiang + 1)) % mod) / 2 * c) % mod;
		ans += (a * xiang) % mod;
	}else {
		ull x1 = sumsqr(min1(x, y) + 1);
		ull x2 = sumsqr(max1(x, y) + 1);
		if(x1 > x2) x2 += mod;
		ull a = x2 - x1;
		ull c = max1(x, y) - min1(x, y);
		ull xiang = min1(x, y);
		ans += (a * (xiang + 1)) % mod;
		ull ans1 = (((xiang * (xiang + 1)) % mod) / 2 * c) % mod;
		if(ans < ans1) ans += mod;
		ans -= ans1;
	}
	return ans % mod;
}
inline double dsumsqr(double n){
	double ans = n * (n + 1) * (2 * n + 1) / 6;
	return ans;
}
inline double dcount(ull x, ull y){
	if(x == y){
		x++, y++;
		return double(x * y) * double(x * y + 1) / 2;
	}
	double ans = min1(x, y) + 1;
	ans = (ans * ans) * (ans * ans + 1) / 2;
	if(y < x){
		double x1 = dsumsqr(min1(x, y));
		double x2 = dsumsqr(max1(x, y));
		double a = x2 - x1;
		double c = max1(x, y) - min1(x, y);
		double xiang = min1(x, y) + 1;
		ans += (xiang * (xiang + 1)) / 2 * c;
		ans += a * xiang;
	}else {
		double x1 = sumsqr(min1(x, y) + 1);
		double x2 = sumsqr(max1(x, y) + 1);
		double a = x2 - x1;
		double c = max1(x, y) - min1(x, y);
		double xiang = min1(x, y);
		ans += a * (xiang + 1);
		double ans1 = (xiang * (xiang + 1)) / 2 * c;
		ans -= ans1;
	}
	return ans;
}
int main(){
//	freopen("input.txt","r", stdin);
//	ifstream cin("input.txt");
	int n;
	scanf("%d", &n);
	for(int i = 0; i < n; i++){
		scanf("%I64u%I64u%I64u%I64u", &x1, &yy, &x2, &y2);
		x1--; yy--; x2--; y2--;
		swap(x1, yy); swap(x2, y2);
		ull ans = count(x2, y2);
		double dans = dcount(x2, y2);
		if(x1 > 0 && yy > 0){
			ans += count(x1 - 1, yy - 1);
			dans += dcount(x1 - 1, yy - 1);
		}
		ans += mod;
		if(x1 > 0){
			ans -= count (x1 - 1, y2);
			dans -= dcount(x1 - 1, y2);
		}
		ans += mod;
		if(yy > 0){
			ans -= count (x2, yy - 1);
			dans -= dcount(x2, yy - 1);
		}
		ans %= mod;
		if(dans > mod){
			printf("...");
			ull ans1 = ans;
			int i = 0;
			for(; ans > 0; i++) ans /= 10;
			for(int j = i; j < 10; j++) printf("0");
			printf("%I64u\n", ans1);
		} else printf("%I64u\n", ans);
	}

	return 0;
}