1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

long long factorial(long long n); //Factorial
long long factorial(long long n, long long x ); // Factorial with modulo
bool isPowerOfTwo (long long x); //Function to check if x is power of 2
long long binpow(long long a, long long b); // return a ^ b
long long binpow(long long a, long long b, long long m); // return (a^b) mod m
long long lcm (long long a, long long b); // least common multiple
long long gcd(long long a, long long b, long long& x, long long& y); //extended euclidean algorithm
pair<long long, long long> fib (long long n); // n-th and (n+1)-th Fibonacci numbers
//dfs
long long mostSignificantDigit(long long N );
long long numberOfDigits(long long N );







typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<pair<int,int>> pi;
typedef vector<pair<long long,long long>> pll;


#define F first
#define S second
#define PB push_back
#define MP make_pair
#define REP(i,a,b) for (int i = a; i <= b; i++)
#define REPA(i,a,b,c) for (int i = a; i <= b; i+=c)


//TRICKS

//Checking if the number is even or odd without using the % operator:
/*
if (num & 1) 
	cout << "ODD"; 
else
	cout << "EVEN"; 
*/

//emplace_back() instead of push_back()
/*
// are all of the elements positive?
all_of(first, first+n, ispositive()); 

// is there at least one positive element?
any_of(first, first+n, ispositive());

// are none of the elements positive?
none_of(first, first+n, ispositive()); 


Copy Algorithm: used to copy elements from one container to another.
// copy 5 elements from source to target
copy_n(source, sizeOfArray, target);

Initialization in Binary form
auto number = 0b011; 
cout << number;
OUTPUT: 3

*/


const int N_MAX = 1000123;

int n;
int a [ N_MAX ];
int maxValue;
unordered_map<int,int>counter;

int main() {
	ios_base::sync_with_stdio(0);

    cin >> n;
    REP(i,1,n) {
        cin >> a [ i ];
    }
    REP(firstIndex,1,n) {
        REP(lastIndex,firstIndex,n) {
            vector<int>v;
            REP(i,firstIndex,lastIndex) {
                v.PB(a[i]);
            }
            sort(v.begin(), v.end());
            int value = 0;
            int substringSize = v.size();
            value += substringSize;
            if(substringSize % 2 == 0) {
                value += v [ substringSize/2 ];
                value += v [ (substringSize/2) - 1  ];
            }
            else {
                value += v [ substringSize / 2 ] * 2;
            }
            counter[value]++;
            maxValue = max(value, maxValue);
            //cout << firstIndex << "-" << lastIndex << ": " << value << '\n';
        }
    }

    cout << maxValue << ' ' <<  counter[maxValue] << '\n';

	return 0;
}
/*
5
3 4 1 2 5

5
1 2 3 4 5

5
5 1 2 4 3

*/











long long factorial(long long n) 
{ 
    if (n == 0) 
        return 1; 
    return n * factorial(n - 1); 
} 

long long factorial(long long n, long long x ) {
    ll res = 1;
    for ( ll i = 1; i <= n; i++ ) {
        res *= i;
        res %= x;
    }
    return res;
}




// return a ^ b
long long binpow(long long a, long long b) {
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
}

// return (a^b) mod m
long long binpow(long long a, long long b, long long m) {
    a %= m;
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a % m;
        a = a * a % m;
        b >>= 1;
    }
    return res;
}
// least common multiple
long long lcm (long long a, long long b) {
    return a / __gcd(a, b) * b;
}
//extended euclidean algorithm
long long gcd(long long a, long long b, long long& x, long long& y) {
    x = 1, y = 0;
    long long x1 = 0, y1 = 1, a1 = a, b1 = b;
    while (b1) {
        long long q = a1 / b1;
        tie(x, x1) = make_tuple(x1, x - q * x1);
        tie(y, y1) = make_tuple(y1, y - q * y1);
        tie(a1, b1) = make_tuple(b1, a1 - q * b1);
    }
    return a1;
}
// n-th and (n+1)-th Fibonacci numbers
pair<long long, long long> fib (long long n) {
    if (n == 0)
        return {0, 1};

    auto p = fib(n >> 1);
    long long c = p.first * (2 * p.second - p.first);
    long long d = p.first * p.first + p.second * p.second;
    if (n & 1)
        return {d, c + d};
    else
        return {c, d};
}

//dfs
/*
void dfs(int v ) {
    visited[v] = true;
    for (int i = 0; i < (int) G [ v ].size(); i++ ) {
    	int u = G [ v ] [ i ];
        if (!visited[u])
            dfs(u);
    }
}
*/

//bfs
/*




*/


/* Function to check if x is power of 2*/
bool isPowerOfTwo (long long x) 
{ 
  /* First x in the below expression is  
    for the case when x is 0 */
  return x && (!(x&(x-1))); 
} 

long long mostSignificantDigit(long long N ) {
	long double K = log10(N);
	K = K - floor(K);
	long long X = pow(10, K);
	return X;
}
long long numberOfDigits(long long N ) {
	N = floor(log10(N)) + 1;
	return N;
}