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
#include <bits/stdc++.h>
using namespace std;

const int N = 1e6 + 5;

int tab[N];
int poz[N];

set <pair <int, int> > s;

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	
	int n;
	cin >> n;
	
	for(int i = 1; i <= n; i++){
		cin >> tab[i];
		poz[tab[i]] = i;
	}
	
	cout << n * 2 + 1 << " ";
	
	int ile = 0;
	//int p = poz[n], k = poz[n];
	//s.insert(make_pair(p, k));
		
	for(int i = 1; i <= n; i++){
		vector <int> v;
		for(int j = i; j <= n; j++){
			v.push_back(tab[j]);
			sort(v.begin(), v.end());
			//cout << tab[j] << " " << v.size() << " " << v[n / 2] << "\n";
			//for(auto x : v) cout << x << " ";
			//cout << "\n";
			
			//if(v.size() % 2 == 0) cout << i << " a " << j << " " << v[n / 2] + v[n / 2 - 1] + v.size() << "\n";
			//else cout << i << " " << j << " b " << v[n / 2] * 2 + v.size() << "\n";
			if(v.size() % 2 == 0 && v[v.size() / 2] + v[v.size() / 2 - 1] + v.size() == n * 2 + 1)
				ile++;
			else if(v.size() % 2 == 1 && v[v.size() / 2] * 2 + v.size() == n * 2 + 1)
				ile++;
		}
	}
		
	cout << ile << "\n";
			
		
}