1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
#include <iostream>
using namespace std;

int main() {
    int MAX = 1000001;
    int n, a[MAX], b[MAX], l, r, ways;
    cin >> n;
    double y = (n + 1) / 2.0;
    for (int i = 0; i < n; i++) { cin >> a[i]; b[i] = a[i] <= y; }
    for (l = 0; l < n && b[l]; l++);
    for (r = 0; r < n && b[n - 1 - r]; r++);
    if (l > 0 && r > 0) ways = 2 * (l + r);
    else ways = l + r + 1;
    ways++;
    if (n == 2) ways = 2;
    if (n == 1) ways = 1;
    cout << 2*n + 1 << " " << ways << endl;
    return 0;
}