#include <iostream>
#include<cstdio>
#include<string.h>
#include<vector>
using namespace std;
pair<int,int> dp[1200000][20];
int a[20],n;
pair<int,int> f(int mask,int rt)
{
int i;
// cout<<mask<<endl;
if(mask==(1<<n)-1)
{
return(make_pair(2*a[rt],1));
}
if(dp[mask][rt].first)
{
return dp[mask][rt];
}
for(i=0; i<n; i++)
{
//cout<<(mask&(i<<i));
if((mask&(1<<i))==0)
{
//cout<<1;
if(a[rt]<a[i])
{
pair<int,int> r = f(mask|(1<<i),i);
if(dp[mask][rt].first<r.first)
{
dp[mask][rt].first=r.first;
dp[mask][rt].second=r.second;
//dp[mask][rt].second=r.second;
}
else if(dp[mask][rt].first==r.first) dp[mask][rt].second+=r.second;
}
else
{
pair<int,int> r= f(mask|(1<<i),i);
if(dp[mask][rt].first<r.first+2*(a[rt]-a[i]))
{
dp[mask][rt].first=r.first+2*(a[rt]-a[i]);
dp[mask][rt].second=r.second;
}
else if(dp[mask][rt].first==r.first+2*(a[rt]-a[i])) dp[mask][rt].second+=r.second;
}
}
}
return dp[mask][rt];
}
int main()
{
int ans=0;
scanf("%d",&n);
while(n)
{
pair<int,int>ans;
ans=make_pair(0,0);
int i;
memset(dp,0,sizeof(dp));
for(i=0; i<n; i++) scanf("%d",&a[i]);
for(i=0; i<n; i++)
{
pair<int,int> tm=f(1<<i,i);
if(ans.first<tm.first)
{
ans.first=tm.first;
ans.second=tm.second;
}
else if(ans.first==tm.first)
{
ans.second+=tm.second;
}
}
printf("%d %d\n",2*n+ans.first,ans.second);
scanf("%d",&n);
}
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZTxjc3RkaW8+CiNpbmNsdWRlPHN0cmluZy5oPgojaW5jbHVkZTx2ZWN0b3I+CnVzaW5nIG5hbWVzcGFjZSBzdGQ7CnBhaXI8aW50LGludD4gZHBbMTIwMDAwMF1bMjBdOwppbnQgYVsyMF0sbjsKcGFpcjxpbnQsaW50PiBmKGludCBtYXNrLGludCBydCkKewogICAgaW50IGk7CiAgICAvLyBjb3V0PDxtYXNrPDxlbmRsOwogICAgaWYobWFzaz09KDE8PG4pLTEpCiAgICB7CiAgICAgICAgcmV0dXJuKG1ha2VfcGFpcigyKmFbcnRdLDEpKTsKICAgIH0KICAgIGlmKGRwW21hc2tdW3J0XS5maXJzdCkKICAgIHsKICAgICAgICByZXR1cm4gZHBbbWFza11bcnRdOwogICAgfQogICAgZm9yKGk9MDsgaTxuOyBpKyspCiAgICB7CiAgICAgICAgLy9jb3V0PDwobWFzayYoaTw8aSkpOwogICAgICAgIGlmKChtYXNrJigxPDxpKSk9PTApCiAgICAgICAgewogICAgICAgICAgICAvL2NvdXQ8PDE7CiAgICAgICAgICAgIGlmKGFbcnRdPGFbaV0pCiAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgIHBhaXI8aW50LGludD4gciA9IGYobWFza3woMTw8aSksaSk7CiAgICAgICAgICAgICAgICBpZihkcFttYXNrXVtydF0uZmlyc3Q8ci5maXJzdCkKICAgICAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgICAgICBkcFttYXNrXVtydF0uZmlyc3Q9ci5maXJzdDsKICAgICAgICAgICAgICAgICAgICBkcFttYXNrXVtydF0uc2Vjb25kPXIuc2Vjb25kOwogICAgICAgICAgICAgICAgICAgIC8vZHBbbWFza11bcnRdLnNlY29uZD1yLnNlY29uZDsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGVsc2UgaWYoZHBbbWFza11bcnRdLmZpcnN0PT1yLmZpcnN0KSBkcFttYXNrXVtydF0uc2Vjb25kKz1yLnNlY29uZDsKICAgICAgICAgICAgfQogICAgICAgICAgICBlbHNlCiAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgIHBhaXI8aW50LGludD4gcj0gZihtYXNrfCgxPDxpKSxpKTsKICAgICAgICAgICAgICAgIGlmKGRwW21hc2tdW3J0XS5maXJzdDxyLmZpcnN0KzIqKGFbcnRdLWFbaV0pKQogICAgICAgICAgICAgICAgewogICAgICAgICAgICAgICAgICAgIGRwW21hc2tdW3J0XS5maXJzdD1yLmZpcnN0KzIqKGFbcnRdLWFbaV0pOwogICAgICAgICAgICAgICAgICAgIGRwW21hc2tdW3J0XS5zZWNvbmQ9ci5zZWNvbmQ7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBlbHNlIGlmKGRwW21hc2tdW3J0XS5maXJzdD09ci5maXJzdCsyKihhW3J0XS1hW2ldKSkgZHBbbWFza11bcnRdLnNlY29uZCs9ci5zZWNvbmQ7CiAgICAgICAgICAgIH0KICAgICAgICB9CiAgICB9CgogICAgcmV0dXJuIGRwW21hc2tdW3J0XTsKfQppbnQgbWFpbigpCnsKICAgIGludCBhbnM9MDsKICAgIHNjYW5mKCIlZCIsJm4pOwogICAgd2hpbGUobikKICAgIHsKICAgICAgICBwYWlyPGludCxpbnQ+YW5zOwogICAgICAgIGFucz1tYWtlX3BhaXIoMCwwKTsKCiAgICAgICAgaW50IGk7CiAgICAgICAgbWVtc2V0KGRwLDAsc2l6ZW9mKGRwKSk7CiAgICAgICAgZm9yKGk9MDsgaTxuOyBpKyspIHNjYW5mKCIlZCIsJmFbaV0pOwogICAgICAgIGZvcihpPTA7IGk8bjsgaSsrKQogICAgICAgIHsKCiAgICAgICAgICAgIHBhaXI8aW50LGludD4gdG09ZigxPDxpLGkpOwogICAgICAgICAgICBpZihhbnMuZmlyc3Q8dG0uZmlyc3QpCiAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgIGFucy5maXJzdD10bS5maXJzdDsKICAgICAgICAgICAgICAgIGFucy5zZWNvbmQ9dG0uc2Vjb25kOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGVsc2UgaWYoYW5zLmZpcnN0PT10bS5maXJzdCkKICAgICAgICAgICAgewogICAgICAgICAgICAgICAgYW5zLnNlY29uZCs9dG0uc2Vjb25kOwogICAgICAgICAgICB9CiAgICAgICAgfQoKICAgICAgICBwcmludGYoIiVkICVkXG4iLDIqbithbnMuZmlyc3QsYW5zLnNlY29uZCk7CiAgICAgICAgc2NhbmYoIiVkIiwmbik7CiAgICB9CiAgICByZXR1cm4gMDsKfQoK