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
#include <bits/stdc++.h>
using namespace std;
int tab[1000002];
int pom[1000002];
int oblicz(int i, int j){
	int n = j - i + 1;
	for(int k = 0, z = i; k < n; k++, z++) pom[k] = tab[z];
	sort(pom, pom + n);
	if(n%2 == 1)return 2*pom[n/2] + n;
	else return pom[(n - 1)/2] + pom[(n+ 1)/2] + n;	
}
int main() {
	ios_base::sync_with_stdio(0);
cin.tie(0);
	cout.tie(0);
	int n, i, j, cel, in;
	long long wyn = 0;
	cin >> n;
	for(i = 0; i < n; i++)  {
		cin >> tab[i];	
		if(tab[i] == n) in = i;
	}
	cel = 2* n + 1;
	for(i = 0; i <= in; i++) {		
		for(j = in; j < n; j++){	
		 if(cel == oblicz(i,j))	 {
		 	//cout << i <<" "<<j << endl;
		 	wyn++;
		 }
		}
	}


	cout << cel <<" " <<wyn ;
	
	return 0;
}