#include <iostream>
#include <vector>
#include <fstream>
#include <algorithm>
#include <iomanip>
#include <cstdio>

using namespace std;

const int MAXN = 142;

int a[MAXN];
int n;

bool cmp(pair<int, int> a, pair<int, int> b) {
    if (a.first == b.first) {
        return a.second < b.second;
    } else {
        return a.first < b.first;
    }
}

int main() {

    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif

    cin >> n;
    //n = 200;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        //a[i] = (i % 2) + 1;
    }

    int x[MAXN];
    int y[MAXN];
    int xSum[MAXN];
    int ySum[MAXN];

    xSum[0] = 0;
    ySum[0] = 0;

    for (int i = 0; i < MAXN; i++) {
        x[i] = 1000000000;
        y[i] = 1000000000;
    }

    int xCount = 0;
    int yCount = 0;

    for (int i = 0; i < n; i++) {
        if (a[i] == 1) {
            x[++xCount] = i;
            if (i == 0) {
                xSum[i] = 1;
                ySum[i] = 0;
            } else {
                xSum[i] = xSum[i - 1] + 1;
                ySum[i] = ySum[i - 1];
            }
        } else {
            y[++yCount] = i;
            if (i == 0) {
                ySum[i] = 1;
                xSum[i] = 0;
            } else {
                ySum[i] = ySum[i - 1] + 1;
                xSum[i] = xSum[i - 1];
            }

        }
    }

    vector<pair<int, int> > answer;

    for (int t = 1; t <= n; t++) {
        int scoreX = 0;
        int scoreY = 0;

        int setX = 0;
        int setY = 0;

        int position = 0;
        int lastWin = -1;

        bool fail = false;

        while (position < n - 1) {
            int xi = x[scoreX + t];
            int yi = y[scoreY + t];

            if (xi < yi) {
                setX++;
                position = xi;
                lastWin = 1;
            } else {
                setY++;
                position = yi;
                lastWin = 2;
            }

            if (position >= n) {
                fail = true;
                break;
            }

            scoreX = xSum[position];
            scoreY = ySum[position];

            if (n == 186 && t > 2) {
                cout << t << " " << position << endl;
            }
        }

        int ans = max(setX, setY);
        int ans1;
        if (ans == setX) {
            ans1 = 1;
        } else {
            ans1 = 2;
        }
        if (position == n - 1 && (!fail) && (setX != setY) && lastWin == ans1) {
            answer.push_back(make_pair(max(setX, setY), t));
        }
    }

    sort(answer.begin(), answer.end(), cmp);

    cout << answer.size() << endl;
    for (int i = 0; i < answer.size(); i++) {
        cout << answer[i].first << " " << answer[i].second << endl;
    }
}


#include <iostream>
#include <vector>
#include <fstream>
#include <algorithm>
#include <iomanip>
#include <cstdio>
#include <cassert>

using namespace std;

const int MAXN = 1e5 + 42;

int a[MAXN];
int n;

bool cmp(pair<int, int> a, pair<int, int> b) {
    if (a.first == b.first) {
        return a.second < b.second;
    } else {
        return a.first < b.first;
    }
}

int main() {

    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif

     cin >> n;
    //n = 200;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        // a[i] = (i % 2) + 1;
    }

    int x[5*MAXN];
    int y[5*MAXN];
    int xSum[5*MAXN];
    int ySum[5*MAXN];

    xSum[0] = 0;
    ySum[0] = 0;

    for (int i = 0; i < 5*MAXN; i++) {
        x[i] = 1000000000;
        y[i] = 1000000000;
    }

    int xCount = 0;
    int yCount = 0;

    for (int i = 0; i < n; i++) {
        if (a[i] == 1) {
            x[++xCount] = i;
            if (i == 0) {
                xSum[i] = 1;
                ySum[i] = 0;
            } else {
                xSum[i] = xSum[i - 1] + 1;
                ySum[i] = ySum[i - 1];
            }
        } else {
            y[++yCount] = i;
            if (i == 0) {
                ySum[i] = 1;
                xSum[i] = 0;
            } else {
                ySum[i] = ySum[i - 1] + 1;
                xSum[i] = xSum[i - 1];
            }

        }
    }

    vector<pair<int, int> > answer;

    for (int t = 1; t <= n; t++) {
        int scoreX = 0;
        int scoreY = 0;

        int setX = 0;
        int setY = 0;

        int position = 0;
        int lastPosition = -1;
        int lastWin = -1;

        bool fail = false;

        while (position < n - 1) {
            int xi = x[scoreX + t];
            int yi = y[scoreY + t];

            if (xi < yi) {
                setX++;
                position = xi;
                lastWin = 1;
            } else {
                setY++;
                position = yi;
                lastWin = 2;
            }

            assert(position > lastPosition);
            lastPosition = position;

            if (position >= n) {
                fail = true;
                break;
            }

            scoreX = xSum[position];
            scoreY = ySum[position];
        }

        int ans = max(setX, setY);
        int ans1;
        if (ans == setX) {
            ans1 = 1;
        } else {
            ans1 = 2;
        }
        if (position == n - 1 && (!fail) && (setX != setY) && lastWin == ans1) {
            answer.push_back(make_pair(max(setX, setY), t));
        }
    }

    sort(answer.begin(), answer.end(), cmp);

    if (n == 1) {
        cout << 1 << endl << "1 1" <<endl;
        return 0;
    }

    cout << answer.size() << endl;
    for (int i = 0; i < answer.size(); i++) {
        cout << answer[i].first << " " << answer[i].second << endl;
    }
}


#include <iostream>
#include <vector>
#include <fstream>
#include <algorithm>
#include <iomanip>
#include <cstdio>

using namespace std;

const int MAXN = 142;

int a[MAXN];
int n;

bool cmp(pair<int, int> a, pair<int, int> b) {
    if (a.first == b.first) {
        return a.second < b.second;
    } else {
        return a.first < b.first;
    }
}

int main() {

    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif

    cin >> n;
    //n = 200;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        //a[i] = (i % 2) + 1;
    }

    int x[MAXN];
    int y[MAXN];
    int xSum[MAXN];
    int ySum[MAXN];

    xSum[0] = 0;
    ySum[0] = 0;

    for (int i = 0; i < MAXN; i++) {
        x[i] = 1000000000;
        y[i] = 1000000000;
    }

    int xCount = 0;
    int yCount = 0;

    for (int i = 0; i < n; i++) {
        if (a[i] == 1) {
            x[++xCount] = i;
            if (i == 0) {
                xSum[i] = 1;
                ySum[i] = 0;
            } else {
                xSum[i] = xSum[i - 1] + 1;
                ySum[i] = ySum[i - 1];
            }
        } else {
            y[++yCount] = i;
            if (i == 0) {
                ySum[i] = 1;
                xSum[i] = 0;
            } else {
                ySum[i] = ySum[i - 1] + 1;
                xSum[i] = xSum[i - 1];
            }

        }
    }

    vector<pair<int, int> > answer;

    for (int t = 1; t <= n; t++) {
        int scoreX = 0;
        int scoreY = 0;

        int setX = 0;
        int setY = 0;

        int position = 0;
        int lastWin = -1;

        bool fail = false;

        while (position < n - 1) {
            int xi = x[scoreX + t];
            int yi = y[scoreY + t];

            if (xi < yi) {
                setX++;
                position = xi;
                lastWin = 1;
            } else {
                setY++;
                position = yi;
                lastWin = 2;
            }

            if (position >= n) {
                fail = true;
                break;
            }

            scoreX = xSum[position];
            scoreY = ySum[position];

            if (n == 186) {
                cout << t << " " << position << endl;
            }
        }

        int ans = max(setX, setY);
        int ans1;
        if (ans == setX) {
            ans1 = 1;
        } else {
            ans1 = 2;
        }
        if (position == n - 1 && (!fail) && (setX != setY) && lastWin == ans1) {
            answer.push_back(make_pair(max(setX, setY), t));
        }
    }

    sort(answer.begin(), answer.end(), cmp);

    cout << answer.size() << endl;
    for (int i = 0; i < answer.size(); i++) {
        cout << answer[i].first << " " << answer[i].second << endl;
    }
}


#include <iostream>
#include <vector>
#include <fstream>
#include <algorithm>
#include <iomanip>
#include <cstdio>

using namespace std;

const int MAXN = 142;

int a[MAXN];
int n;

bool cmp(pair<int, int> a, pair<int, int> b) {
    if (a.first == b.first) {
        return a.second < b.second;
    } else {
        return a.first < b.first;
    }
}

int main() {

    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif

     cin >> n;
    //n = 200;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        // a[i] = (i % 2) + 1;
    }

    int x[5*MAXN];
    int y[5*MAXN];
    int xSum[5*MAXN];
    int ySum[5*MAXN];

    xSum[0] = 0;
    ySum[0] = 0;

    for (int i = 0; i < MAXN; i++) {
        x[i] = 1000000000;
        y[i] = 1000000000;
    }

    int xCount = 0;
    int yCount = 0;

    for (int i = 0; i < n; i++) {
        if (a[i] == 1) {
            x[++xCount] = i;
            if (i == 0) {
                xSum[i] = 1;
                ySum[i] = 0;
            } else {
                xSum[i] = xSum[i - 1] + 1;
                ySum[i] = ySum[i - 1];
            }
        } else {
            y[++yCount] = i;
            if (i == 0) {
                ySum[i] = 1;
                xSum[i] = 0;
            } else {
                ySum[i] = ySum[i - 1] + 1;
                xSum[i] = xSum[i - 1];
            }

        }
    }

    vector<pair<int, int> > answer;

    for (int t = 1; t <= n; t++) {
        int scoreX = 0;
        int scoreY = 0;

        int setX = 0;
        int setY = 0;

        int position = 0;
        int lastWin = -1;

        bool fail = false;

        while (position < n - 1) {
            int xi = x[scoreX + t];
            int yi = y[scoreY + t];

            if (xi < yi) {
                setX++;
                position = xi;
                lastWin = 1;
            } else {
                setY++;
                position = yi;
                lastWin = 2;
            }

            if (position >= n) {
                fail = true;
                break;
            }

            scoreX = xSum[position];
            scoreY = ySum[position];
        }

        int ans = max(setX, setY);
        int ans1;
        if (ans == setX) {
            ans1 = 1;
        } else {
            ans1 = 2;
        }
        if (position == n - 1 && (!fail) && (setX != setY) && lastWin == ans1) {
            answer.push_back(make_pair(max(setX, setY), t));
        }
    }

    sort(answer.begin(), answer.end(), cmp);

    cout << answer.size() << endl;
    for (int i = 0; i < answer.size(); i++) {
        cout << answer[i].first << " " << answer[i].second << endl;
    }
}


#include <iostream>
#include <vector>
#include <fstream>
#include <algorithm>
#include <iomanip>
#include <cstdio>

using namespace std;

const int MAXN = 142;

int a[MAXN];
int n;

bool cmp(pair<int, int> a, pair<int, int> b) {
    if (a.first == b.first) {
        return a.second < b.second;
    } else {
        return a.first < b.first;
    }
}

int main() {

    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif

    // cin >> n;
    n = 200;
    for (int i = 0; i < n; i++) {
        //cin >> a[i];
        a[i] = (i % 2) + 1;
    }

    int x[5*MAXN];
    int y[5*MAXN];
    int xSum[5*MAXN];
    int ySum[5*MAXN];

    xSum[0] = 0;
    ySum[0] = 0;

    for (int i = 0; i < MAXN; i++) {
        x[i] = 1000000000;
        y[i] = 1000000000;
    }

    int xCount = 0;
    int yCount = 0;

    for (int i = 0; i < n; i++) {
        if (a[i] == 1) {
            x[++xCount] = i;
            if (i == 0) {
                xSum[i] = 1;
                ySum[i] = 0;
            } else {
                xSum[i] = xSum[i - 1] + 1;
                ySum[i] = ySum[i - 1];
            }
        } else {
            y[++yCount] = i;
            if (i == 0) {
                ySum[i] = 1;
                xSum[i] = 0;
            } else {
                ySum[i] = ySum[i - 1] + 1;
                xSum[i] = xSum[i - 1];
            }

        }
    }

    vector<pair<int, int> > answer;

    for (int t = 1; t <= n; t++) {
        int scoreX = 0;
        int scoreY = 0;

        int setX = 0;
        int setY = 0;

        int position = 0;
        int lastWin = -1;

        bool fail = false;

        while (position < n - 1) {
            int xi = x[scoreX + t];
            int yi = y[scoreY + t];

            if (xi < yi) {
                setX++;
                position = xi;
                lastWin = 1;
            } else {
                setY++;
                position = yi;
                lastWin = 2;
            }

            if (position >= n) {
                fail = true;
                break;
            }

            scoreX = xSum[position];
            scoreY = ySum[position];
        }

        int ans = max(setX, setY);
        int ans1;
        if (ans == setX) {
            ans1 = 1;
        } else {
            ans1 = 2;
        }
        if (position == n - 1 && (!fail) && (setX != setY) && lastWin == ans1) {
            answer.push_back(make_pair(max(setX, setY), t));
        }
    }

    sort(answer.begin(), answer.end(), cmp);

    cout << answer.size() << endl;
    for (int i = 0; i < answer.size(); i++) {
        cout << answer[i].first << " " << answer[i].second << endl;
    }
}


#include <iostream>
#include <vector>
#include <fstream>
#include <algorithm>
#include <iomanip>
#include <cstdio>

using namespace std;

const int MAXN = 142;

int a[MAXN];
int n;

bool cmp(pair<int, int> a, pair<int, int> b) {
    if (a.first == b.first) {
        return a.second < b.second;
    } else {
        return a.first < b.first;
    }
}

int main() {

    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif

    cin >> n;
    //n = 200;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        //a[i] = (i % 2) + 1;
    }

    int x[MAXN];
    int y[MAXN];
    int xSum[MAXN];
    int ySum[MAXN];

    xSum[0] = 0;
    ySum[0] = 0;

    for (int i = 0; i < MAXN; i++) {
        x[i] = 1000000000;
        y[i] = 1000000000;
    }

    int xCount = 0;
    int yCount = 0;

    for (int i = 0; i < n; i++) {
        if (a[i] == 1) {
            x[++xCount] = i;
            if (i == 0) {
                xSum[i] = 1;
                ySum[i] = 0;
            } else {
                xSum[i] = xSum[i - 1] + 1;
                ySum[i] = ySum[i - 1];
            }
        } else {
            y[++yCount] = i;
            if (i == 0) {
                ySum[i] = 1;
                xSum[i] = 0;
            } else {
                ySum[i] = ySum[i - 1] + 1;
                xSum[i] = xSum[i - 1];
            }

        }
    }

    vector<pair<int, int> > answer;

    for (int t = 1; t <= n; t++) {
        int scoreX = 0;
        int scoreY = 0;

        int setX = 0;
        int setY = 0;

        int position = 0;
        int lastWin = -1;

        bool fail = false;

        while (position < n - 1) {
            int xi = x[scoreX + t];
            int yi = y[scoreY + t];

            if (xi < yi) {
                setX++;
                position = xi;
                lastWin = 1;
            } else {
                setY++;
                position = yi;
                lastWin = 2;
            }

            if (position >= n) {
                fail = true;
                break;
            }

            scoreX = xSum[position];
            scoreY = ySum[position];

            if (n == 186 && t > 0) {
                cout << t << " " << position << endl;
            }
        }

        int ans = max(setX, setY);
        int ans1;
        if (ans == setX) {
            ans1 = 1;
        } else {
            ans1 = 2;
        }
        if (position == n - 1 && (!fail) && (setX != setY) && lastWin == ans1) {
            answer.push_back(make_pair(max(setX, setY), t));
        }
    }

    sort(answer.begin(), answer.end(), cmp);

    cout << answer.size() << endl;
    for (int i = 0; i < answer.size(); i++) {
        cout << answer[i].first << " " << answer[i].second << endl;
    }
}


#include <iostream>
#include <vector>
#include <fstream>
#include <algorithm>
#include <iomanip>
#include <cstdio>

using namespace std;

const int MAXN = 142;

int a[MAXN];
int n;

bool cmp(pair<int, int> a, pair<int, int> b) {
    if (a.first == b.first) {
        return a.second < b.second;
    } else {
        return a.first < b.first;
    }
}

int main() {

    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif

    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }

    int x[MAXN];
    int y[MAXN];
    int xSum[MAXN];
    int ySum[MAXN];

    xSum[0] = 0;
    ySum[0] = 0;

    for (int i = 0; i < MAXN; i++) {
        x[i] = 1000000000;
        y[i] = 1000000000;
    }

    int xCount = 0;
    int yCount = 0;

    for (int i = 0; i < n; i++) {
        if (a[i] == 1) {
            x[++xCount] = i;
            if (i == 0) {
                xSum[i] = 1;
                ySum[i] = 0;
            } else {
                xSum[i] = xSum[i - 1] + 1;
                ySum[i] = ySum[i - 1];
            }
        } else {
            y[++yCount] = i;
            if (i == 0) {
                ySum[i] = 1;
                xSum[i] = 0;
            } else {
                ySum[i] = ySum[i - 1] + 1;
                xSum[i] = xSum[i - 1];
            }

        }
    }

    vector<pair<int, int> > answer;

    for (int t = 1; t <= n; t++) {
        int scoreX = 0;
        int scoreY = 0;

        int setX = 0;
        int setY = 0;

        int position = 0;
        int lastWin = -1;

        bool fail = false;

        while (position < n - 1) {
            int xi = x[scoreX + t];
            int yi = y[scoreY + t];

            if (xi < yi) {
                setX++;
                position = xi;
                lastWin = 1;
            } else {
                setY++;
                position = yi;
                lastWin = 2;
            }

            if (position >= n) {
                fail = true;
                break;
            }

            scoreX = xSum[position];
            scoreY = ySum[position];
        }

        int ans = max(setX, setY);
        int ans1;
        if (ans == setX) {
            ans1 = 1;
        } else {
            ans1 = 2;
        }
        if (position == n - 1 && (!fail) && (setX != setY) && lastWin == ans1) {
            answer.push_back(make_pair(max(setX, setY), t));
        }
    }

    sort(answer.begin(), answer.end(), cmp);

    cout << answer.size() << endl;
    for (int i = 0; i < answer.size(); i++) {
        cout << answer[i].first << " " << answer[i].second << endl;
    }
}


#include <iostream>
#include <vector>
#include <fstream>
#include <algorithm>
#include <iomanip>
#include <cstdio>
#include <cassert>

using namespace std;

const int MAXN = 142;

int a[MAXN];
int n;

bool cmp(pair<int, int> a, pair<int, int> b) {
    if (a.first == b.first) {
        return a.second < b.second;
    } else {
        return a.first < b.first;
    }
}

int main() {

    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif

     cin >> n;
    //n = 200;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        // a[i] = (i % 2) + 1;
    }

    int x[5*MAXN];
    int y[5*MAXN];
    int xSum[5*MAXN];
    int ySum[5*MAXN];

    xSum[0] = 0;
    ySum[0] = 0;

    for (int i = 0; i < 5*MAXN; i++) {
        x[i] = 1000000000;
        y[i] = 1000000000;
    }

    int xCount = 0;
    int yCount = 0;

    for (int i = 0; i < n; i++) {
        if (a[i] == 1) {
            x[++xCount] = i;
            if (i == 0) {
                xSum[i] = 1;
                ySum[i] = 0;
            } else {
                xSum[i] = xSum[i - 1] + 1;
                ySum[i] = ySum[i - 1];
            }
        } else {
            y[++yCount] = i;
            if (i == 0) {
                ySum[i] = 1;
                xSum[i] = 0;
            } else {
                ySum[i] = ySum[i - 1] + 1;
                xSum[i] = xSum[i - 1];
            }

        }
    }

    vector<pair<int, int> > answer;

    for (int t = 1; t <= n; t++) {
        int scoreX = 0;
        int scoreY = 0;

        int setX = 0;
        int setY = 0;

        int position = 0;
        int lastPosition = -1;
        int lastWin = -1;

        bool fail = false;

        while (position < n - 1) {
            int xi = x[scoreX + t];
            int yi = y[scoreY + t];

            if (xi < yi) {
                setX++;
                position = xi;
                lastWin = 1;
            } else {
                setY++;
                position = yi;
                lastWin = 2;
            }

            assert(position > lastPosition);
            lastPosition = position;

            if (position >= n) {
                fail = true;
                break;
            }

            scoreX = xSum[position];
            scoreY = ySum[position];
        }

        int ans = max(setX, setY);
        int ans1;
        if (ans == setX) {
            ans1 = 1;
        } else {
            ans1 = 2;
        }
        if (position == n - 1 && (!fail) && (setX != setY) && lastWin == ans1) {
            answer.push_back(make_pair(max(setX, setY), t));
        }
    }

    sort(answer.begin(), answer.end(), cmp);

    cout << answer.size() << endl;
    for (int i = 0; i < answer.size(); i++) {
        cout << answer[i].first << " " << answer[i].second << endl;
    }
}


#include <iostream>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>

using namespace std;

const int N = 2 * 1e5 + 100;
const int INF = 1e9;

int a[N];

int w[N], l[N], W[N], L[N];

vector<pair<int, int> >ans;

int main()
{
    int n;
    cin >> n;

    for (int i=1; i<=n; i++)
        cin >> a[i];

    int winner = a[n];

    for (int i=1; i<N; i++)
        w[i] = l[i] = INF;

    for (int i=1; i<=n; i++)
    {
        W[i] = W[i-1];
        L[i] = L[i-1];
        if (a[i] == winner)
        {
            W[i]++;
            w[W[i]] = i;
        }
        else
        {
            L[i]++;
            l[L[i]] = i;
        }
    }

    int WIN = W[n];
    int LOSE = L[n];

    for (int i=1; i<=n; i++)
    {
        int win = 0, lose = 0;
        int sw = 0, sl = 0;
        int lastw=0, lastl=0;
        while (win < WIN)
        {

            int ww = w[win + i];
            int ll = l[lose + i];

            if (ww == INF && ll == INF)
                break;

            if (ww < ll)
            {
                sw++;
                lastw = ww;
            }
            else
            {
                sl++;
                lastl = ll;
            }

            int pos = min(ll, ww);

            win = W[pos];
            lose = L[pos];
        }

        if (sw > sl && lastw == n)
            ans.push_back(make_pair(sw, i));
    }

    sort(ans.begin(), ans.end());

    cout << ans.size() << "\n";

    for (int i=0; i<ans.size(); i++)
        cout << ans[i].first << " " << ans[i].second << "\n";
}


#include <iostream>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>

using namespace std;

const int N = 1e5;

int a[N];
vector<int> d;
bool flag[N];
vector<pair<int, int> >ans;

int main()
{
    int n;
    cin >> n;

    for (int i=0; i<n; i++)
        cin >> a[i];

    int winner = a[n-1];

    int s = 0;
    for (int i=0; i<n; i++)
        if (a[i] == winner)
            s++;

    for (int i=1; i*i<=n; i++)
        if (s % i == 0)
        {
            d.push_back(i);
            if (s/i != i)
                d.push_back(s/i);
        }

    for (int j=0; j<d.size(); j++)
    {
        int t = d[j], p = s/d[j];
        int w = 0, l = 0;
        int W = 0, L = 0;

        for (int i=0; i<n; i++)
        {
            if (a[i] == winner)
                w++;
            else
                l++;
            if (l == t)
            {
                L++;
                w=0;
                l=0;
            }
            if (w == t)
            {
                W++;
                w=0;
                l=0;
            }
            if (L == p)
            {
                flag[j]=1;
                break;
            }
        }
        if ( W != p)
            flag[j] = 1;
    }

    for (int i=0; i<d.size(); i++)
        if (!flag[i])
            ans.push_back(make_pair(s/d[i], d[i]));

    sort(ans.begin(), ans.end());

    cout << ans.size() << "\n";

    for (int i=0; i<ans.size(); i++)
        cout << ans[i].first << " " << ans[i].second << "\n";
}


#include <iostream>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>

using namespace std;

const int N = 1 * 1e5 + 100;
const int INF = 1e9;

int a[N];

int w[N], l[N], W[N], L[N];

vector<pair<int, int> >ans;

int main()
{
    int n;
    cin >> n;

    for (int i=1; i<=n; i++)
        cin >> a[i];

    int winner = a[n];

    for (int i=1; i<N; i++)
        w[i] = l[i] = INF;

    for (int i=1; i<=n; i++)
    {
        W[i] = W[i-1];
        L[i] = L[i-1];
        if (a[i] == winner)
        {
            W[i]++;
            w[W[i]] = i;
        }
        else
        {
            L[i]++;
            l[L[i]] = i;
        }
    }

    int WIN = W[n];
    int LOSE = L[n];

    for (int i=1; i<=n; i++)
    {
        int win = 0, lose = 0;
        int sw = 0, sl = 0;
        int lastw=0, lastl=0;
        while (win < WIN)
        {

            int ww = w[win + i];
            int ll = l[lose + i];

            if (ww == INF && ll == INF)
                break;

            if (ww < ll)
            {
                sw++;
                lastw = ww;
            }
            else
            {
                sl++;
                lastl = ll;
            }

            int pos = min(ll, ww);

            win = W[pos];
            lose = L[pos];
        }

        if (sw > sl && lastw == n)
            ans.push_back(make_pair(sw, i));
    }

    sort(ans.begin(), ans.end());

    cout << ans.size() << "\n";

    for (int i=0; i<ans.size(); i++)
        cout << ans[i].first << " " << ans[i].second << "\n";
}


#include <iostream>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>

using namespace std;

const int N = 1e5+100;

int a[N];
int w[N], l[N], W[N], L[N];
vector<pair<int, int> >ans;

int main()
{
    int n;
    cin >> n;

    for (int i=1; i<=n; i++)
        cin >> a[i];

    int winner = a[n];

    for (int i=1; i<N; i++)
        w[i] = l[i] = N;

    for (int i=1; i<=n; i++)
    {
        W[i] = W[i-1];
        L[i] = L[i-1];
        if (a[i] == winner)
        {
            W[i]++;
            w[W[i]] = i;
        }
        else
        {
            L[i]++;
            l[L[i]] = i;
        }
    }

    int WIN = W[n];
    int LOSE = L[n];

    for (int i=1; i<=n; i++)
    {
        int win = 0, lose = 0;
        int sw = 0, sl = 0;
        int lastw=0, lastl=0;
        while (true)
        {
            int ww = w[win + i];
            int ll = l[lose + i];

            if (ww == N && ll == N)
                break;
            if (ww < ll)
            {
                sw++;
                lastw=ww;
            }
            else
            {
                sl++;
                lastl=ll;
            }
            int pos = min(ll, ww);
            win = W[pos];
            lose = L[pos];
        }
        if (sw > sl && lastw == n)
        {
            ans.push_back(make_pair(sw, i));
        }
    }

    sort(ans.begin(), ans.end());

    cout << ans.size() << "\n";

    for (int i=0; i<ans.size(); i++)
        cout << ans[i].first << " " << ans[i].second << "\n";
}


#include <iostream>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>

using namespace std;

const int N = 1e5+100;

int a[N];
int w[N], l[N], W[N], L[N];
vector<pair<int, int> >ans;

int main()
{
    int n;
    cin >> n;

    for (int i=1; i<=n; i++)
        cin >> a[i];

    int winner = a[n];

    for (int i=1; i<N; i++)
        w[i] = l[i] = N;

    for (int i=1; i<=n; i++)
    {
        W[i] = W[i-1];
        L[i] = L[i-1];
        if (a[i] == winner)
        {
            W[i]++;
            w[W[i]] = i;
        }
        else
        {
            L[i]++;
            l[L[i]] = i;
        }
    }

    int WIN = W[n];
    int LOSE = L[n];

    for (int i=1; i<=n; i++)
    {
        int win = 0, lose = 0;
        int sw = 0, sl = 0;
        int lastw=0, lastl=0;
        while (true)
        {
            int ww = w[win + i];
            int ll = l[lose + i];

            if (ww == N && ll == N)
                break;
            if (ww < ll)
            {
                sw++;
                lastw=ww;
            }
            else
            {
                sl++;
                lastl=ll;
            }
            int pos = min(ll, ww);
            if ((n-pos)/i+sw <= sl)
                break;
            win = W[pos];
            lose = L[pos];
        }
        if (sw > sl && lastw == n)
        {
            ans.push_back(make_pair(sw, i));
        }
    }

    sort(ans.begin(), ans.end());

    cout << ans.size() << "\n";

    for (int i=0; i<ans.size(); i++)
        cout << ans[i].first << " " << ans[i].second << "\n";
}


#include <iostream>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>

using namespace std;

const int N = 1e5+100;

int a[N];
int w[N], l[N], W[N], L[N];
vector<pair<int, int> >ans;

int main()
{
    int n;
    cin >> n;

    for (int i=1; i<=n; i++)
        cin >> a[i];

    int winner = a[n];

    for (int i=1; i<N; i++)
        w[i] = l[i] = N;

    for (int i=1; i<=n; i++)
    {
        W[i] = W[i-1];
        L[i] = L[i-1];
        if (a[i] == winner)
        {
            W[i]++;
            w[W[i]] = i;
        }
        else
        {
            L[i]++;
            l[L[i]] = i;
        }
    }

    int WIN = W[n];
    int LOSE = L[n];

    for (int i=1; i<=WIN; i++)
    {
        int win = 0, lose = 0;
        int sw = 0, sl = 0;
        int lastw=0, lastl=0;
        while (true)
        {
            int ww = w[win + i];
            int ll = l[lose + i];

            if (ww == N && ll == N)
                break;
            if (ww < ll)
            {
                sw++;
                lastw=ww;
            }
            else
            {
                sl++;
                lastl=ll;
            }
            int pos = min(ll, ww);
            if ((n-pos)/i+sw <= sl)
                break;
            win = W[pos];
            lose = L[pos];
        }
        if (sw > sl && lastw == n)
        {
            ans.push_back(make_pair(sw, i));
        }
    }

    sort(ans.begin(), ans.end());

    cout << ans.size() << "\n";

    for (int i=0; i<ans.size(); i++)
        cout << ans[i].first << " " << ans[i].second << "\n";
}


#include <iostream>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>

using namespace std;

const int N = 1e5+100;

int a[N];
vector<int> d;
bool flag[N];
vector<pair<int, int> >ans;

int main()
{
    int n;
    cin >> n;

    for (int i=0; i<n; i++)
        cin >> a[i];

    int winner = a[n-1];

    int s = 0;
    for (int i=0; i<n; i++)
        if (a[i] == winner)
            s++;

    for (int i=1; i*i<=n; i++)
        if (s % i == 0)
        {
            d.push_back(i);
            if (s/i != i)
                d.push_back(s/i);
        }

    for (int j=0; j<d.size(); j++)
    {
        int t = d[j], p = s/d[j];
        int w = 0, l = 0;
        int W = 0, L = 0;

        for (int i=0; i<n; i++)
        {
            if (a[i] == winner)
                w++;
            else
                l++;
            if (l == t)
            {
                L++;
                w=0;
                l=0;
            }
            if (w == t)
            {
                W++;
                w=0;
                l=0;
            }
            if (L == p)
            {
                flag[j]=1;
                break;
            }
        }
        if ( W != p || w != 0 || l != 0)
            flag[j] = 1;
    }

    for (int i=0; i<d.size(); i++)
        if (!flag[i])
            ans.push_back(make_pair(s/d[i], d[i]));

    sort(ans.begin(), ans.end());

    cout << ans.size() << "\n";

    for (int i=0; i<ans.size(); i++)
        cout << ans[i].first << " " << ans[i].second << "\n";
}


#include <iostream>
#include <vector>
#include <string.h>
#include <algorithm>
#include <stdio.h>

using namespace std;

const int Max=110000;

int a[Max];
int p1[Max];
int p2[Max];
int mp1[Max];
int mp2[Max];
int n;

void input()
{
    memset(mp1,63,sizeof(mp1));
    memset(mp2,63,sizeof(mp2));
    mp1[0]=mp2[0]=p2[0]=p1[0]=a[0]=0;
    for(int i=1;i<=n;i++) scanf("%d",&a[i]);
    int t=a[n];
    for(int i=1;i<=n;i++)
    {
        if(a[i]==t)
        {
            p1[i]=p1[i-1]+1;
            mp1[p1[i]]=i;
            p2[i]=p2[i-1];
        }
        if(a[i]!=t)
        {
            p2[i]=p2[i-1]+1;
            mp2[p2[i]]=i;
            p1[i]=p1[i-1];
        }
    }
}

int solve(int z)
{
    int now=0;
    int l=0,r=0;
    int Count=0;
    while(1)
    {
        int a=mp1[p1[now]+z];
        int b=mp2[p2[now]+z];
        if(a<b){
            now=a;
            l++;
        }
        else if(a>b){
            now=b;
            r++;
        }
        if(a>n||b>n) return -1;
        if(a==b) return -1;
        //cout<<now<<endl;
        //else cout<<"error"<<endl;
        if(now==n&&l>r){
            return l;
        }
        if(now>=n){
            return -1;
        }
        //if(++Count>=n/z) return -1;  //гаbugЃЌД§ЯћГ§
    }
}
vector<pair<int,int> > ans;

bool comp(pair<int,int> a,pair<int,int> b)
{
    if(a.first==b.first) return a.second<b.second;
    else return a.first<b.first;
}

int main()
{
    cin>>n;
    input();
    for(int i=1;i<=n;i++)
    {
        int temp=solve(i);
        if(temp!=-1)
        {
            ans.push_back(make_pair(temp,i));
        }
    }
    sort(ans.begin(),ans.end(),comp);
    cout<<ans.size()<<endl;
    for(int i=0;i<(int)ans.size();i++)
    {
        printf("%d %d\n",ans[i].first,ans[i].second);
    }
    //cout << "Hello world!" << endl;
    return 0;
}


#include <iostream>
#include <vector>
#include <string.h>
#include <algorithm>
#include <stdio.h>

using namespace std;

const int Max=110000;

int a[Max];
int p1[Max];
int p2[Max];
int mp1[Max];
int mp2[Max];
int n;

void input()
{
    memset(mp1,63,sizeof(mp1));
    memset(mp2,63,sizeof(mp2));
    mp1[0]=mp2[0]=p2[0]=p1[0]=a[0]=0;
    for(int i=1;i<=n;i++) scanf("%d",&a[i]);
    int t=a[n];
    for(int i=1;i<=n;i++)
    {
        if(a[i]==t)
        {
            p1[i]=p1[i-1]+1;
            mp1[p1[i]]=i;
            p2[i]=p2[i-1];
        }
        if(a[i]!=t)
        {
            p2[i]=p2[i-1]+1;
            mp2[p2[i]]=i;
            p1[i]=p1[i-1];
        }
    }
}

int solve(int z)
{
    int now=0;
    int l=0,r=0;
    int Count=0;
    while(1)
    {
        int a=mp1[p1[now]+z];
        int b=mp2[p2[now]+z];
        if(a<b){
            now=a;
            l++;
        }
        else if(a>b){
            now=b;
            r++;
        }
        if(a==b) return -1;
        //cout<<now<<endl;
        //else cout<<"error"<<endl;
        if(now==n&&l>r){
            return l;
        }
        if(now>=n){
            return -1;
        }
        if(++Count>=n/z) return -1;  //有bug，待消除
    }
}
vector<pair<int,int> > ans;

bool comp(pair<int,int> a,pair<int,int> b)
{
    if(a.first==b.first) return a.second<b.second;
    else return a.first<b.first;
}

int main()
{
    cin>>n;
    input();
    for(int i=1;i<=n;i++)
    {
        int temp=solve(i);
        if(temp!=-1)
        {
            ans.push_back(make_pair(temp,i));
        }
    }
    sort(ans.begin(),ans.end(),comp);
    cout<<ans.size()<<endl;
    for(int i=0;i<(int)ans.size();i++)
    {
        printf("%d %d\n",ans[i].first,ans[i].second);
    }
    //cout << "Hello world!" << endl;
    return 0;
}


#include <iostream>
#include <vector>
#include <string.h>
#include <algorithm>
#include <stdio.h>

using namespace std;

const int Max=110000;

int a[Max];
int p1[Max];
int p2[Max];
int mp1[Max];
int mp2[Max];
int n;

void input()
{
    memset(mp1,63,sizeof(mp1));
    memset(mp2,63,sizeof(mp2));
    //memset(p1,0,sizeof(p1));
    //memset(p2,0,sizeof(p2));
    mp1[0]=mp2[0]=p2[0]=p1[0]=a[0]=0;
    for(int i=1;i<=n;i++) scanf("%d",&a[i]);
    int t=a[n];
    for(int i=1;i<=n;i++)
    {
        if(a[i]==t)
        {
            p1[i]=p1[i-1]+1;
            mp1[p1[i]]=i;
            p2[i]=p2[i-1];
        }
        if(a[i]!=t)
        {
            p2[i]=p2[i-1]+1;
            mp2[p2[i]]=i;
            p1[i]=p1[i-1];
        }
    }
}

int solve(int z)
{
    int now=0;
    int l=0,r=0;
    int Count=0;
    while(1)
    {
        int a=mp1[p1[now]+z];
        int b=mp2[p2[now]+z];
        if(a<b&&a<=n){
            now=a;
            l++;
        }
        else if(a>b&&b<=n){
            now=b;
            r++;
        }
        else return -1;
        //cout<<now<<endl;
        //else cout<<"error"<<endl;
        if(now==n&&l>r){
            return l;
        }
        if(now>=n){
            return -1;
        }
        //if(++Count>=n/z) return -1;  //гаbugЃЌД§ЯћГ§
    }
}
vector<pair<int,int> > ans;

bool comp(pair<int,int> a,pair<int,int> b)
{
    if(a.first==b.first) return a.second<b.second;
    else return a.first<b.first;
}

int main()
{
    cin>>n;
    input();
    for(int i=1;i<=n;i++)
    {
        int temp=solve(i);
        if(temp!=-1)
        {
            ans.push_back(make_pair(temp,i));
        }
    }
    sort(ans.begin(),ans.end(),comp);
    cout<<ans.size()<<endl;
    for(int i=0;i<(int)ans.size();i++)
    {
        printf("%d %d\n",ans[i].first,ans[i].second);
    }
    //cout << "Hello world!" << endl;
    return 0;
}


#include <iostream>
#include <vector>
#include <string.h>
#include <algorithm>
#include <stdio.h>

using namespace std;

const int Max=110000;

int a[Max];
int p1[Max];
int p2[Max];
int mp1[Max];
int mp2[Max];
int n;

void input()
{
    memset(mp1,63,sizeof(mp1));
    memset(mp2,63,sizeof(mp2));
    memset(p1,0,sizeof(p1));
    memset(p2,0,sizeof(p2));
    mp1[0]=mp2[0]=p2[0]=p1[0]=a[0]=0;
    for(int i=1;i<=n;i++) scanf("%d",&a[i]);
    int t=a[n];
    for(int i=1;i<=n;i++)
    {
        if(a[i]==t)
        {
            p1[i]=p1[i-1]+1;
            mp1[p1[i]]=i;
            p2[i]=p2[i-1];
        }
        if(a[i]!=t)
        {
            p2[i]=p2[i-1]+1;
            mp2[p2[i]]=i;
            p1[i]=p1[i-1];
        }
    }
}

int solve(int z)
{
    int now=0;
    int l=0,r=0;
    int Count=0;
    while(1)
    {
        int a=mp1[p1[now]+z];
        int b=mp2[p2[now]+z];
        if(a<b){
            now=a;
            l++;
        }
        else if(a>b){
            now=b;
            r++;
        }
        if(a==b) return -1;
        //cout<<now<<endl;
        //else cout<<"error"<<endl;
        if(now==n&&l>r){
            return l;
        }
        if(now>=n){
            return -1;
        }
        //if(++Count>=n/z) return -1;  //гаbugЃЌД§ЯћГ§
    }
}
vector<pair<int,int> > ans;

bool comp(pair<int,int> a,pair<int,int> b)
{
    if(a.first==b.first) return a.second<b.second;
    else return a.first<b.first;
}

int main()
{
    cin>>n;
    input();
    for(int i=1;i<=n;i++)
    {
        int temp=solve(i);
        if(temp!=-1)
        {
            ans.push_back(make_pair(temp,i));
        }
    }
    sort(ans.begin(),ans.end(),comp);
    cout<<ans.size()<<endl;
    for(int i=0;i<(int)ans.size();i++)
    {
        printf("%d %d\n",ans[i].first,ans[i].second);
    }
    //cout << "Hello world!" << endl;
    return 0;
}


#include <iostream>
#include <vector>
#include <string.h>
#include <algorithm>
#include <stdio.h>

using namespace std;

const int Max=110000;

int a[Max];
int p1[Max];
int p2[Max];
int mp1[Max];
int mp2[Max];
int n;

void input()
{
    memset(mp1,63,sizeof(mp1));
    memset(mp2,63,sizeof(mp2));
    //memset(p1,0,sizeof(p1));
    //memset(p2,0,sizeof(p2));
    mp1[0]=mp2[0]=p2[0]=p1[0]=a[0]=0;
    for(int i=1;i<=n;i++) scanf("%d",&a[i]);
    int t=a[n];
    for(int i=1;i<=n;i++)
    {
        if(a[i]==t)
        {
            p1[i]=p1[i-1]+1;
            mp1[p1[i]]=i;
            p2[i]=p2[i-1];
        }
        else if(a[i]!=t)
        {
            p2[i]=p2[i-1]+1;
            mp2[p2[i]]=i;
            p1[i]=p1[i-1];
        }
    }
}

int solve(int z)
{
    int now=0;
    int l=0,r=0;
    int Count=0;
    while(1)
    {
        int a=mp1[p1[now]+z];
        int b=mp2[p2[now]+z];
        if(a<b&&a<=n){
            now=a;
            l++;
        }
        else if(a>b&&b<=n){
            now=b;
            r++;
        }
        else return -1;
        //cout<<now<<endl;
        //else cout<<"error"<<endl;
        if(now==n&&l>r){
            return l;
        }
        if(now+z>n){
            return -1;
        }
        //if(++Count>=n/z+1) return -1;  //гаbugЃЌД§ЯћГ§
    }
}
vector<pair<int,int> > ans;

bool comp(pair<int,int> a,pair<int,int> b)
{
    if(a.first==b.first) return a.second<b.second;
    else return a.first<b.first;
}

int main()
{
    cin>>n;
    input();
    for(int i=1;i<=n;i++)
    {
        int temp=solve(i);
        if(temp!=-1)
        {
            ans.push_back(make_pair(temp,i));
        }
    }
    sort(ans.begin(),ans.end(),comp);
    cout<<ans.size()<<endl;
    for(int i=0;i<(int)ans.size();i++)
    {
        printf("%d %d\n",ans[i].first,ans[i].second);
    }
    //cout << "Hello world!" << endl;
    return 0;
}


#include <iostream>
#include <vector>
#include <string.h>
#include <algorithm>
#include <stdio.h>

using namespace std;

const int Max=110000;

int a[Max];
int p1[Max];
int p2[Max];
int mp1[Max];
int mp2[Max];
int n;

void input()
{
    memset(mp1,63,sizeof(mp1));
    memset(mp2,63,sizeof(mp2));
    mp1[0]=mp2[0]=p2[0]=p1[0]=a[0]=0;
    for(int i=1;i<=n;i++) scanf("%d",&a[i]);
    int t=a[n];
    for(int i=1;i<=n;i++)
    {
        if(a[i]==t)
        {
            p1[i]=p1[i-1]+1;
            mp1[p1[i]]=i;
            p2[i]=p2[i-1];
        }
        if(a[i]!=t)
        {
            p2[i]=p2[i-1]+1;
            mp2[p2[i]]=i;
            p1[i]=p1[i-1];
        }
    }
}

int solve(int z)
{
    int now=0;
    int l=0,r=0;
    while(1)
    {
        int a=mp1[p1[now]+z];
        int b=mp2[p2[now]+z];
        if(a<b){
            now=a;
            l++;
        }
        else if(a>b){
            now=b;
            r++;
        }
        if(a==b) return -1;
        //cout<<now<<endl;
        //else cout<<"error"<<endl;
        if(now==n&&l>r){
            return l;
        }
        if(now>=n){
            return -1;
        }
    }
}
vector<pair<int,int> > ans;

bool comp(pair<int,int> a,pair<int,int> b)
{
    if(a.first==b.first) return a.second<b.second;
    else return a.first<b.first;
}

int main()
{
    cin>>n;
    input();
    for(int i=1;i<=n;i++)
    {
        int temp=solve(i);
        if(temp!=-1)
        {
            ans.push_back(make_pair(temp,i));
        }
    }
    sort(ans.begin(),ans.end(),comp);
    cout<<ans.size()<<endl;
    for(int i=0;i<(int)ans.size();i++)
    {
        printf("%d %d\n",ans[i].first,ans[i].second);
    }
    //cout << "Hello world!" << endl;
    return 0;
}


#include <iostream>
#include <vector>
#include <string.h>
#include <algorithm>
#include <stdio.h>

using namespace std;

const int Max=110000;

int a[Max];
int p1[Max];
int p2[Max];
int mp1[Max];
int mp2[Max];
int n;

void input()
{
    memset(mp1,63,sizeof(mp1));
    memset(mp2,63,sizeof(mp2));
    mp1[0]=mp2[0]=p2[0]=p1[0]=a[0]=0;
    for(int i=1;i<=n;i++) scanf("%d",&a[i]);
    int t=a[n];
    for(int i=1;i<=n;i++)
    {
        if(a[i]==t)
        {
            p1[i]=p1[i-1]+1;
            mp1[p1[i]]=i;
            p2[i]=p2[i-1];
        }
        if(a[i]!=t)
        {
            p2[i]=p2[i-1]+1;
            mp2[p2[i]]=i;
            p1[i]=p1[i-1];
        }
    }
}

int solve(int z)
{
    int now=0;
    int l=0,r=0;
    int Count=0;
    while(1)
    {
        int a=mp1[p1[now]+z];
        int b=mp2[p2[now]+z];
        if(a<b){
            now=a;
            l++;
        }
        else if(a>b){
            now=b;
            r++;
        }
        if(a==b) return -1;
        //cout<<now<<endl;
        //else cout<<"error"<<endl;
        if(now==n&&l>r){
            return l;
        }
        if(now>=n){
            return -1;
        }
        if(Count++>=n/z) return -1;
    }
}
vector<pair<int,int> > ans;

bool comp(pair<int,int> a,pair<int,int> b)
{
    if(a.first==b.first) return a.second<b.second;
    else return a.first<b.first;
}

int main()
{
    cin>>n;
    input();
    for(int i=1;i<=n;i++)
    {
        int temp=solve(i);
        if(temp!=-1)
        {
            ans.push_back(make_pair(temp,i));
        }
    }
    sort(ans.begin(),ans.end(),comp);
    cout<<ans.size()<<endl;
    for(int i=0;i<(int)ans.size();i++)
    {
        printf("%d %d\n",ans[i].first,ans[i].second);
    }
    //cout << "Hello world!" << endl;
    return 0;
}


#include <iostream>
#include <vector>
#include <string.h>
#include <algorithm>
#include <stdio.h>

using namespace std;

const int Max=110000;

int a[Max];
int p1[Max];
int p2[Max];
int mp1[Max];
int mp2[Max];
int n;

void input()
{
    memset(mp1,63,sizeof(mp1));
    memset(mp2,63,sizeof(mp2));
    //memset(p1,0,sizeof(p1));
    //memset(p2,0,sizeof(p2));
    mp1[0]=mp2[0]=p2[0]=p1[0]=a[0]=0;
    for(int i=1;i<=n;i++) scanf("%d",&a[i]);
    int t=a[n];
    for(int i=1;i<=n;i++)
    {
        if(a[i]==t)
        {
            p1[i]=p1[i-1]+1;
            mp1[p1[i]]=i;
            p2[i]=p2[i-1];
        }
        else if(a[i]!=t)
        {
            p2[i]=p2[i-1]+1;
            mp2[p2[i]]=i;
            p1[i]=p1[i-1];
        }
    }
}

int solve(int z)
{
    if(z>n/2&&z!=p1[n]) return -1;
    int now=0;
    int l=0,r=0;
    //int Count=0;
    while(1)
    {
        int a=mp1[p1[now]+z];
        int b=mp2[p2[now]+z];
        if(a<b&&a<=n){
            now=a;
            l++;
        }
        else if(a>b&&b<=n){
            now=b;
            r++;
        }
        else return -1;
        //cout<<now<<endl;
        //else cout<<"error"<<endl;
        if(now==n&&l>r){
            return l;
        }
        if(now+z>n){
            return -1;
        }
        //if(++Count>=n/z+1) return -1;  //гаbugЃЌД§ЯћГ§
    }
}
vector<pair<int,int> > ans;

bool comp(pair<int,int> a,pair<int,int> b)
{
    if(a.first==b.first) return a.second<b.second;
    else return a.first<b.first;
}

int main()
{
    cin>>n;
    input();
    for(int i=1;i<=n;i++)
    {
        int temp=solve(i);
        if(temp!=-1)
        {
            ans.push_back(make_pair(temp,i));
        }
    }
    sort(ans.begin(),ans.end(),comp);
    cout<<ans.size()<<endl;
    for(int i=0;i<(int)ans.size();i++)
    {
        printf("%d %d\n",ans[i].first,ans[i].second);
    }
    //cout << "Hello world!" << endl;
    return 0;
}


#include <iostream>
#include <vector>
#include <string.h>
#include <algorithm>
#include <stdio.h>

using namespace std;

const int Max=110000;

int a[Max];
int p1[Max];
int p2[Max];
int mp1[Max];
int mp2[Max];
int n;

void input()
{
    memset(mp1,63,sizeof(mp1));
    memset(mp2,63,sizeof(mp2));
    //memset(p1,0,sizeof(p1));
    //memset(p2,0,sizeof(p2));
    mp1[0]=mp2[0]=p2[0]=p1[0]=a[0]=0;
    for(int i=1;i<=n;i++) scanf("%d",&a[i]);
    int t=a[n];
    for(int i=1;i<=n;i++)
    {
        if(a[i]==t)
        {
            p1[i]=p1[i-1]+1;
            mp1[p1[i]]=i;
            p2[i]=p2[i-1];
        }
        else if(a[i]!=t)
        {
            p2[i]=p2[i-1]+1;
            mp2[p2[i]]=i;
            p1[i]=p1[i-1];
        }
    }
}

int solve(int z)
{
    int now=0,last=-1;
    int l=0,r=0;
    int Count=0;
    while(1)
    {
        int a=mp1[p1[now]+z];
        int b=mp2[p2[now]+z];
        if(a<b&&a<=n){
            now=a;
            l++;
        }
        else if(a>b&&b<=n){
            now=b;
            r++;
        }
        else return -1;
        //cout<<now<<endl;
        //else cout<<"error"<<endl;
        if(now==n&&l>r){
            return l;
        }
        if(now>=n){
            return -1;
        }
        if(last!=now) last=now;
        else
        {
            cout<<last<<endl;
            return -1;
        }
        //if(++Count>=n/z) return -1;  //гаbugЃЌД§ЯћГ§
    }
}
vector<pair<int,int> > ans;

bool comp(pair<int,int> a,pair<int,int> b)
{
    if(a.first==b.first) return a.second<b.second;
    else return a.first<b.first;
}

int main()
{
    cin>>n;
    input();
    for(int i=1;i<=n;i++)
    {
        int temp=solve(i);
        if(temp!=-1)
        {
            ans.push_back(make_pair(temp,i));
        }
    }
    sort(ans.begin(),ans.end(),comp);
    cout<<ans.size()<<endl;
    for(int i=0;i<(int)ans.size();i++)
    {
        printf("%d %d\n",ans[i].first,ans[i].second);
    }
    //cout << "Hello world!" << endl;
    return 0;
}


#include <iostream>
#include <vector>
#include <string.h>
#include <algorithm>
#include <stdio.h>

using namespace std;

const int Max=110000;

int a[Max];
int p1[Max];
int p2[Max];
int mp1[Max];
int mp2[Max];
int n;

void input()
{
    memset(mp1,63,sizeof(mp1));
    memset(mp2,63,sizeof(mp2));
    //memset(p1,0,sizeof(p1));
    //memset(p2,0,sizeof(p2));
    mp1[0]=mp2[0]=p2[0]=p1[0]=a[0]=0;
    for(int i=1;i<=n;i++) scanf("%d",&a[i]);
    int t=a[n];
    for(int i=1;i<=n;i++)
    {
        if(a[i]==t)
        {
            p1[i]=p1[i-1]+1;
            mp1[p1[i]]=i;
            p2[i]=p2[i-1];
        }
        else if(a[i]!=t)
        {
            p2[i]=p2[i-1]+1;
            mp2[p2[i]]=i;
            p1[i]=p1[i-1];
        }
    }
}

int solve(int z)
{
    //if(z>n/2&&z!=p1[n]) return -1;
    int now=0;
    int l=0,r=0;
    //int Count=0;
    while(1)
    {
        int a=mp1[p1[now]+z];
        int b=mp2[p2[now]+z];
        if(a<b&&a<=n){
            now=a;
            l++;
        }
        else if(a>b&&b<=n){
            now=b;
            r++;
        }
        else return -1;
        //cout<<now<<endl;
        //else cout<<"error"<<endl;
        if(now==n&&l>r){
            return l;
        }
        if(now+z>n){
            return -1;
        }
        //if(++Count>=n/z+1) return -1;  //гаbugЃЌД§ЯћГ§
    }
}
vector<pair<int,int> > ans;

bool comp(pair<int,int> a,pair<int,int> b)
{
    if(a.first==b.first) return a.second<b.second;
    else return a.first<b.first;
}

int main()
{
    cin>>n;
    input();
    for(int i=1;i<=p1[n];i++)
    {
        int temp=solve(i);
        if(temp!=-1)
        {
            ans.push_back(make_pair(temp,i));
        }
    }
    sort(ans.begin(),ans.end(),comp);
    cout<<ans.size()<<endl;
    for(int i=0;i<(int)ans.size();i++)
    {
        printf("%d %d\n",ans[i].first,ans[i].second);
    }
    //cout << "Hello world!" << endl;
    return 0;
}


#include <iostream>
#include <vector>
#include <string.h>
#include <algorithm>
#include <stdio.h>

using namespace std;

const int Max=110000;

int a[Max];
int p1[Max];
int p2[Max];
int mp1[Max];
int mp2[Max];
int n;

void input()
{
    memset(mp1,63,sizeof(mp1));
    memset(mp2,63,sizeof(mp2));
    //memset(p1,0,sizeof(p1));
    //memset(p2,0,sizeof(p2));
    mp1[0]=mp2[0]=p2[0]=p1[0]=a[0]=0;
    for(int i=1;i<=n;i++) scanf("%d",&a[i]);
    int t=a[n];
    for(int i=1;i<=n;i++)
    {
        if(a[i]==t)
        {
            p1[i]=p1[i-1]+1;
            mp1[p1[i]]=i;
            p2[i]=p2[i-1];
        }
        else if(a[i]!=t)
        {
            p2[i]=p2[i-1]+1;
            mp2[p2[i]]=i;
            p1[i]=p1[i-1];
        }
    }
}

int solve(int z)
{
    if(z>n/2&&z!=p1[n]) return -1;
    int now=0;
    int l=0,r=0;
    //int Count=0;
    while(1)
    {
        int a=mp1[p1[now]+z];
        int b=mp2[p2[now]+z];
        if(a<b&&a<=n){
            now=a;
            l++;
        }
        else if(a>b&&b<=n){
            now=b;
            r++;
        }
        else return -1;
        //cout<<now<<endl;
        //else cout<<"error"<<endl;
        if(now==n&&l>r){
            return l;
        }
        if(now+z>n){
            return -1;
        }
        //if(++Count>=n/z+1) return -1;  //гаbugЃЌД§ЯћГ§
    }
}
vector<pair<int,int> > ans;

bool comp(pair<int,int> a,pair<int,int> b)
{
    if(a.first==b.first) return a.second<b.second;
    else return a.first<b.first;
}

int main()
{
    cin>>n;
    input();
    for(int i=1;i<=p1[n];i++)
    {
        int temp=solve(i);
        if(temp!=-1)
        {
            ans.push_back(make_pair(temp,i));
        }
    }
    sort(ans.begin(),ans.end(),comp);
    cout<<ans.size()<<endl;
    for(int i=0;i<(int)ans.size();i++)
    {
        printf("%d %d\n",ans[i].first,ans[i].second);
    }
    //cout << "Hello world!" << endl;
    return 0;
}


#include <iostream>
#include <vector>
#include <string.h>
#include <algorithm>
#include <stdio.h>

using namespace std;

const int Max=110000;

int a[Max];
int p1[Max];
int p2[Max];
int mp1[Max];
int mp2[Max];
int n;

void input()
{
    memset(mp1,63,sizeof(mp1));
    memset(mp2,63,sizeof(mp2));
    //memset(p1,0,sizeof(p1));
    //memset(p2,0,sizeof(p2));
    mp1[0]=mp2[0]=p2[0]=p1[0]=a[0]=0;
    for(int i=1;i<=n;i++) scanf("%d",&a[i]);
    int t=a[n];
    for(int i=1;i<=n;i++)
    {
        if(a[i]==t)
        {
            p1[i]=p1[i-1]+1;
            mp1[p1[i]]=i;
            p2[i]=p2[i-1];
        }
        else if(a[i]!=t)
        {
            p2[i]=p2[i-1]+1;
            mp2[p2[i]]=i;
            p1[i]=p1[i-1];
        }
    }
}

int solve(int z)
{
    int now=0;
    int l=0,r=0;
    int Count=0;
    while(1)
    {
        int a=mp1[p1[now]+z];
        int b=mp2[p2[now]+z];
        if(a<b&&a<=n){
            now=a;
            l++;
        }
        else if(a>b&&b<=n){
            now=b;
            r++;
        }
        else return -1;
        //cout<<now<<endl;
        //else cout<<"error"<<endl;
        if(now==n&&l>r){
            return l;
        }
        if(now>=n){
            return -1;
        }
        if(Count==n/z)
        {
            cout<<now<<endl;
            return -1;
        }
        if(++Count>=n/z+1) return -1;  //гаbugЃЌД§ЯћГ§
    }
}
vector<pair<int,int> > ans;

bool comp(pair<int,int> a,pair<int,int> b)
{
    if(a.first==b.first) return a.second<b.second;
    else return a.first<b.first;
}

int main()
{
    cin>>n;
    input();
    for(int i=1;i<=n;i++)
    {
        int temp=solve(i);
        if(temp!=-1)
        {
            ans.push_back(make_pair(temp,i));
        }
    }
    sort(ans.begin(),ans.end(),comp);
    cout<<ans.size()<<endl;
    for(int i=0;i<(int)ans.size();i++)
    {
        printf("%d %d\n",ans[i].first,ans[i].second);
    }
    //cout << "Hello world!" << endl;
    return 0;
}


#include <iostream>
#include <vector>
#include <string.h>
#include <algorithm>
#include <stdio.h>

using namespace std;

const int Max=110000;

int a[Max];
int p1[Max];
int p2[Max];
int mp1[Max];
int mp2[Max];
int n;

void input()
{
    memset(mp1,63,sizeof(mp1));
    memset(mp2,63,sizeof(mp2));
    mp1[0]=mp2[0]=p2[0]=p1[0]=a[0]=0;
    for(int i=1;i<=n;i++) scanf("%d",&a[i]);
    int t=a[n];
    for(int i=1;i<=n;i++)
    {
        if(a[i]==t)
        {
            p1[i]=p1[i-1]+1;
            mp1[p1[i]]=i;
            p2[i]=p2[i-1];
        }
        if(a[i]!=t)
        {
            p2[i]=p2[i-1]+1;
            mp2[p2[i]]=i;
            p1[i]=p1[i-1];
        }
    }
}

int solve(int z)
{
    int now=0;
    int l=0,r=0;
    int Count=0;
    while(1)
    {
        int a=mp1[p1[now]+z];
        int b=mp2[p2[now]+z];
        if(a<b){
            now=a;
            l++;
        }
        else if(a>b){
            now=b;
            r++;
        }
        if(a==b) return -1;
        //cout<<now<<endl;
        //else cout<<"error"<<endl;
        if(now==n&&l>r){
            return l;
        }
        if(now>=n){
            return -1;
        }
        if(Count++==n) return -1;
    }
}
vector<pair<int,int> > ans;

bool comp(pair<int,int> a,pair<int,int> b)
{
    if(a.first==b.first) return a.second<b.second;
    else return a.first<b.first;
}

int main()
{
    cin>>n;
    input();
    for(int i=1;i<=n;i++)
    {
        int temp=solve(i);
        if(temp!=-1)
        {
            ans.push_back(make_pair(temp,i));
        }
    }
    sort(ans.begin(),ans.end(),comp);
    cout<<ans.size()<<endl;
    for(int i=0;i<(int)ans.size();i++)
    {
        printf("%d %d\n",ans[i].first,ans[i].second);
    }
    //cout << "Hello world!" << endl;
    return 0;
}


#include <iostream>
#include <vector>
#include <string.h>
#include <algorithm>
#include <stdio.h>

using namespace std;

const int Max=110000;

int a[Max];
int p1[Max];
int p2[Max];
int mp1[Max];
int mp2[Max];
int n;

void input()
{
    memset(mp1,63,sizeof(mp1));
    memset(mp2,63,sizeof(mp2));
    //memset(p1,0,sizeof(p1));
    //memset(p2,0,sizeof(p2));
    mp1[0]=mp2[0]=p2[0]=p1[0]=a[0]=0;
    for(int i=1;i<=n;i++) scanf("%d",&a[i]);
    int t=a[n];
    for(int i=1;i<=n;i++)
    {
        if(a[i]==t)
        {
            p1[i]=p1[i-1]+1;
            mp1[p1[i]]=i;
            p2[i]=p2[i-1];
        }
        else if(a[i]!=t)
        {
            p2[i]=p2[i-1]+1;
            mp2[p2[i]]=i;
            p1[i]=p1[i-1];
        }
    }
}

int solve(int z)
{
    int now=0;
    int l=0,r=0;
    int Count=0;
    while(1)
    {
        int a=mp1[p1[now]+z];
        int b=mp2[p2[now]+z];
        if(a<b&&a<=n){
            now=a;
            l++;
        }
        else if(a>b&&b<=n){
            now=b;
            r++;
        }
        else return -1;
        //cout<<now<<endl;
        //else cout<<"error"<<endl;
        if(now==n&&l>r){
            return l;
        }
        if(now>=n){
            return -1;
        }
        if(Count==n/z)
        {
            cout<<now<<" "<<p1[now]<<" "<<p2[now]<<" "<<endl;
            return -1;
        }
        if(++Count>=n/z+1) return -1;  //гаbugЃЌД§ЯћГ§
    }
}
vector<pair<int,int> > ans;

bool comp(pair<int,int> a,pair<int,int> b)
{
    if(a.first==b.first) return a.second<b.second;
    else return a.first<b.first;
}

int main()
{
    cin>>n;
    input();
    for(int i=1;i<=n;i++)
    {
        int temp=solve(i);
        if(temp!=-1)
        {
            ans.push_back(make_pair(temp,i));
        }
    }
    sort(ans.begin(),ans.end(),comp);
    cout<<ans.size()<<endl;
    for(int i=0;i<(int)ans.size();i++)
    {
        printf("%d %d\n",ans[i].first,ans[i].second);
    }
    //cout << "Hello world!" << endl;
    return 0;
}


#include <iostream>
#include <vector>
#include <string.h>
#include <algorithm>
#include <stdio.h>

using namespace std;

const int Max=110000;

int a[Max];
int p1[Max];
int p2[Max];
int mp1[Max];
int mp2[Max];
int n;

void input()
{
    memset(mp1,63,sizeof(mp1));
    memset(mp2,63,sizeof(mp2));
    //memset(p1,0,sizeof(p1));
    //memset(p2,0,sizeof(p2));
    mp1[0]=mp2[0]=p2[0]=p1[0]=a[0]=0;
    for(int i=1;i<=n;i++) scanf("%d",&a[i]);
    int t=a[n];
    for(int i=1;i<=n;i++)
    {
        if(a[i]==t)
        {
            p1[i]=p1[i-1]+1;
            mp1[p1[i]]=i;
            p2[i]=p2[i-1];
        }
        else if(a[i]!=t)
        {
            p2[i]=p2[i-1]+1;
            mp2[p2[i]]=i;
            p1[i]=p1[i-1];
        }
    }
}

int solve(int z)
{
    int now=0;
    int l=0,r=0;
    int Count=0;
    while(1)
    {
        int a=mp1[p1[now]+z];
        int b=mp2[p2[now]+z];
        if(a<b&&a<=n){
            now=a;
            l++;
        }
        else if(a>b&&b<=n){
            now=b;
            r++;
        }
        else return -1;
        //cout<<now<<endl;
        //else cout<<"error"<<endl;
        if(now==n&&l>r){
            return l;
        }
        if(now>=n){
            return -1;
        }
        if(Count==n/z)
        {
            cout<<z<<"  "<<now<<" "<<p1[now]<<" "<<p2[now]<<" "<<endl;
            return -1;
        }
        if(++Count>=n/z+1) return -1;  //гаbugЃЌД§ЯћГ§
    }
}
vector<pair<int,int> > ans;

bool comp(pair<int,int> a,pair<int,int> b)
{
    if(a.first==b.first) return a.second<b.second;
    else return a.first<b.first;
}

int main()
{
    cin>>n;
    input();
    for(int i=1;i<=n;i++)
    {
        int temp=solve(i);
        if(temp!=-1)
        {
            ans.push_back(make_pair(temp,i));
        }
    }
    sort(ans.begin(),ans.end(),comp);
    cout<<ans.size()<<endl;
    for(int i=0;i<(int)ans.size();i++)
    {
        printf("%d %d\n",ans[i].first,ans[i].second);
    }
    //cout << "Hello world!" << endl;
    return 0;
}


#include <cstdio>
#include <cstring>
#include <vector>
#include <algorithm>

using namespace std;

const int maxn = 2 * 1e5 + 5;
const int inf = 0x3f3f3f3f;
typedef pair<int, int> pii;

vector<pii> ans;
int N, X, L[maxn], R[maxn], pl[maxn], pr[maxn];

void init () {
    for (int i = 0; i < maxn; i++)
        pl[i] = pr[i] = inf;

    scanf("%d", &N);
    for (int i = 1; i <= N; i++) {
        L[i] = L[i-1];
        R[i] = R[i-1];
        scanf("%d", &X);
        if (X == 1)
            L[i]++;
        else
            R[i]++;
    }

    for (int i = 0; i <= N; i++) {
        pl[L[i]] = min(pl[L[i]], i);
        pr[R[i]] = min(pr[R[i]], i);
    }
}

void solve (int t) {
    int sa = 0, sb = 0;
    int pa = t, pb = t;
    int tmp = min(pl[t], pr[t]);

    while (true) {
        if (pl[pa] < pr[pb])
            sa++;
        else if (pl[pa] > pr[pb])
            sb++;
        int tmp = min(pl[pa], pr[pb]);
        if (tmp == N) {
            if (X == 1 && sa > sb)
                ans.push_back(make_pair(sa, t));
            else if (X == 2 && sa < sb)
                ans.push_back(make_pair(sb, t));
            return;
        } else if (tmp > N)
            return;
        pa = L[tmp] + t;
        pb = R[tmp] + t;
    }
}

int main () {
    init();
    for (int i = 1; i <= N; i++)//
        solve(i);

    sort(ans.begin(), ans.end());
    printf("%lu\n", ans.size());
    for (int i = 0; i < ans.size(); i++)
        printf("%d %d\n", ans[i].first, ans[i].second);
    return 0;
}


#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
using namespace std;

long long sqr(long long x) __attribute__((always_inline));

long long sqr(long long x) {
	return x * x;
}

struct Point {
	Point(int x = 0, int y = 0) : x(x), y(y) {}
	Point &operator -=(const Point &o) {
		x -= o.x;
		y -= o.y;
		return *this;
	}
	double norm() const __attribute__((always_inline));
	int x, y;
};

double Point::norm() const {
	return sqrt(sqr(x) + sqr(y));
}

inline Point operator - (Point a, const Point &b) {
	return a -= b;
}

long long det(const Point &a, const Point &b) __attribute__((always_inline));
long long dot(const Point &a, const Point &b) __attribute__((always_inline));
long long get_sum(int i,int j) __attribute__((always_inline));
int nxt(int i) __attribute__((always_inline));
double solve() __attribute__((always_inline));

long long det(const Point &a, const Point &b) {
	return (long long)a.x * b.y - (long long)a.y * b.x;
}

long long dot(const Point &a, const Point &b) {
	return (long long)a.x * b.x + (long long)a.y * b.y;
}

const int N = 40000;

int n;
Point p[N];
long long sum[N + 1];

long long get_sum(int i, int j) {
	long long s = sum[j] - sum[i];
	return i <= j ? s : sum[n] + s;
}

int nxt(int i) {
	return (i + 1) % n;
}

double solve() {
	sum[0] = 0;
	for (int i = 0; i < n; ++ i) sum[i + 1] = sum[i] + det(p[i], p[(i + 1) % n]);
	double result = INFINITY;
	for (int i = 0, j = 0; i < n; ++ i) {
		while (dot(p[nxt(i)] - p[i], p[nxt(j)] - p[j]) > 0) j = nxt(j);
		Point a = p[nxt(i)] - p[i];
		Point b = p[j]       - p[i];
		double n = a.norm();
		result = min(result, det(a, b) / n * dot(a, b) / n - (get_sum(i, j) + det(p[j], p[i])));
		if (i == j) return 0.;
	}
	return .5 * result;
}

int main() {
	scanf("%d", &n);
	for (int i = 0; i < n; ++ i) scanf("%d%d", &p[i].x, &p[i].y);
	solve();
	if (sum[n] < 0) reverse(p, p + n);
	double result = solve();
	for (int i = 0; i < n; ++ i) p[i].x *= -1;
	reverse(p, p + n);
	result = min(result, solve());
	printf("%.10f\n", result);
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 4e4 + 5;
double sqr(double x) {
    return x * x;
}
struct P {
    double x, y;
    P() {}
    P(double _x, double _y) : x(_x), y(_y) {}
    friend P operator - (const P &a, const P &b) {
        return P(a.x - b.x, a.y - b.y);
    }
    friend double operator * (const P &a, const P &b) {
        return a.x * b.x + a.y * b.y;
    }
    friend double operator ^ (const P &a, const P &b) {
        return a.x * b.y - a.y * b.x;
    }
} p[maxn];
double dis(P a, P b) {
    return sqrt(sqr(a.x - b.x) + sqr(a.y - b.y));
}
int n;
int dec(int x) {
    return x - 1;
}
int inc(int x) {
    return (x + 1) % n;
}
double solve() {
    double ans = 1e18, s = 0;
    for(int i = 0, j = 1; i < n; ++i) {
        while((p[inc(j)] - p[j]) * (p[inc(i)] - p[i]) > 0) {
            s += fabs((p[i] - p[j]) ^ (p[i] - p[inc(j)]));
            j = inc(j);
        }
        double a = fabs((p[i] - p[inc(i)]) ^ (p[i] - p[j])) / dis(p[i], p[inc(i)]);
        double c = dis(p[i], p[j]);
        double b = sqrt(sqr(c) - sqr(a));
        double area = a * b;
        ans = min(ans, fabs(fabs(area) - fabs(s)));
        s -= fabs((p[j] - p[i]) ^ (p[inc(i)] - p[i]));
    }
    return ans * 0.5;
}
int main() {
    scanf("%d", &n);
    for(int i = 0; i < n; ++i) scanf("%lf%lf", &p[i].x, &p[i].y);
    double ans = solve();
    reverse(p, p + n);
    printf("%.15f\n", min(ans, solve()));
    return 0;
}
 			  		 		 			  	  		        	//hellobig_tq


#include<bits/stdc++.h>
using namespace std;
#define X real()
#define Y imag()
typedef long long ll;
typedef double ld;
typedef complex<ld> point;
const ld eps=1e-9;
const int MAX=1e5+9;
int n;
point a[MAX],z;
ld ans=1e18;
ld cross(point a,point b){return a.X*b.Y-b.X*a.Y;}
ld dot(point a,point b){return a.X*b.X+a.Y*b.Y;}
ld cross(point a,point b,point c){return abs(cross(b-a,c-a));}
ld dot(point a,point b,point c){return dot(b-a,c-a);}
ld p(ld x){return x*x;}
ld dis(point a,point b){return p(a.X-b.X)+p(a.Y-b.Y);}
void cal()
{
	int p=1;
	ld sum=0;
	for (int i=0;i<n;i++)
	{
		while (dot(a[i],a[p],a[(i+1)%n])<dot(a[i],a[(p+1)%n],a[(i+1)%n])) sum+=cross(a[i],a[p],a[(p+1)%n]),p=(p+1)%n;
		ans=min(ans,dot(a[i],a[p],a[(i+1)%n])/dis(a[i],a[(i+1)%n])*cross(a[i],a[p],a[(i+1)%n])/2.0-sum/2.0);
		sum-=abs(cross(a[p],a[i],a[(i+1)%n]));
	}
}
int main()
{
	ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
	cin>>n;
	for (int i=0,x,y;i<n;i++) cin>>x>>y,a[i]={1.0*x,1.0*y};
	cal(),reverse(a,a+n),cal();
	cout<<fixed<<setprecision(9)<<ans<<endl;
	return 0;
}


// default code for competitive programming
// c2251393 ver 3.141 {{{

// Includes
#include <bits/stdc++.h>

// Defines
#define NAME(x) #x
#define SZ(c) (int)(c).size()
#define ALL(c) (c).begin(), (c).end()
#define FOR(it, c) for(__typeof((c).begin()) it = (c).begin(); it != (c).end(); it++)
#define REP(i, s, e) for(int i = (s); i <= (e); i++)
#define REPD(i, s, e) for(int i = (s); i >= (e); i--)
#define IOS ios_base::sync_with_stdio( 0 )
#define DEBUG 1
#define fst first
#define snd second
#ifdef ONLINE_JUDGE
#define FILE( fn ) \
    freopen(fn".in","r",stdin); \
    freopen(fn".out","w",stdout);
#else
#define FILE( fn )
#endif

using namespace std;

// Typedefs
typedef double real;
typedef long long ll;
typedef pair<ll, int> pli;
typedef tuple<ll, int> tli;
typedef pair<int, int> pii;
typedef tuple<int, int> tii;
typedef unsigned long long ull;

// Some common const.
const double EPS = -1e8;
const double Pi = acos(-1);

// Equal for double
bool inline equ(double a, double b)
{return fabs(a - b) < EPS;}

// }}}
// start ~~QAQ~~

struct Pt
{
  typedef ll T;
  T x , y;
  Pt operator+(Pt a){return Pt{x+a.x,y+a.y};}
  Pt operator-(Pt a){return Pt{x-a.x,y-a.y};}
  T operator%(Pt a){return x*a.y-y*a.x;}
  T operator*(Pt a){return x*a.x+y*a.y;}
  void input(){cin >> x >> y;}
};

const int MAXN = 40010;
const ll  INF  = 10000000000000ll;

int n;
Pt p[ MAXN ];

inline int nxt( int id ){return id==n?1:id+1;}
inline int prv( int id ){return id==1?n:id-1;}

ll sum[ MAXN ];

inline ll sq( ll x ){return x*x;}

inline ll get_sum( int l , int r )
{
  if( l <= r ) return sum[ r ] - sum[ l - 1 ];
  return sum[ r ] + sum[ n ] - sum[ l - 1 ];
}

double solve()
{
  sum[ 0 ] = 0ll;
  REP( i , 1 , n )
    sum[ i ] = sum[ i - 1 ] + ( p[ i ] % p[ nxt( i ) ] );
  int j = 1;
  double res = 1e15;
  //printf( "area %lld\n" , sum[ n ] );
  REP( i , 1 , n )
  {
    //printf( "  now %d %lld %lld\n" , i , p[i].x , p[i].y );
    while( ( p[ nxt( i ) ] - p[ i ] ) * ( p[ nxt( j ) ] - p[ j ] ) > 0ll )
      j = nxt( j );
    //printf( "    j %d\n" , j );
    //printf( "    get sum %d %d %lld\n" , i , prv( j ) , get_sum( i , prv( j ) ) );
    if( i == j ) return 0.0;
    Pt a = p[ nxt( i ) ] - p[ i ];
    Pt b = p[ j ] - p[ i ];
    double an = sqrt(sq(a.x)+sq(a.y));
    double adb = a * b;
    double acb = a % b;
    res = min( res , ( adb / an ) * ( acb / an ) - ( get_sum( i , prv( j ) ) + p[ j ] % p[ i ] ) );
  }
  return res * 0.5;
}

int main()
{
  //IOS;
  cin >> n;
  REP( i , 1 , n ) p[ i ].input();
  if( ( p[ 2 ] - p[ 1 ] ) % ( p[ 3 ] - p[ 2 ] ) < 0ll )
    reverse( p + 1 , p + 1 + n );
  double ans1 = solve();
  REP( i , 1 , n ) p[ i ].x *= -1ll;
  reverse( p + 1 , p + 1 + n );
  double ans2 = solve();
  double ac = min( ans1 , ans2 );
  //cout << ac << '\n';
  printf( "%.10f\n" , ac );
}


// default code for competitive programming
// c2251393 ver 3.141 {{{

// Includes
#include <bits/stdc++.h>

// Defines
#define NAME(x) #x
#define SZ(c) (int)(c).size()
#define ALL(c) (c).begin(), (c).end()
#define FOR(it, c) for(__typeof((c).begin()) it = (c).begin(); it != (c).end(); it++)
#define REP(i, s, e) for(int i = (s); i <= (e); i++)
#define REPD(i, s, e) for(int i = (s); i >= (e); i--)
#define IOS ios_base::sync_with_stdio( 0 )
#define DEBUG 1
#define fst first
#define snd second
#ifdef ONLINE_JUDGE
#define FILE( fn ) \
    freopen(fn".in","r",stdin); \
    freopen(fn".out","w",stdout);
#else
#define FILE( fn )
#endif

using namespace std;

// Typedefs
typedef double real;
typedef long long ll;
typedef pair<ll, int> pli;
typedef tuple<ll, int> tli;
typedef pair<int, int> pii;
typedef tuple<int, int> tii;
typedef unsigned long long ull;

// Some common const.
const double EPS = -1e8;
const double Pi = acos(-1);

// Equal for double
bool inline equ(double a, double b)
{return fabs(a - b) < EPS;}

// }}}
// start ~~QAQ~~

struct Pt
{
  typedef ll T;
  T x , y;
  Pt operator+(Pt a){return Pt{x+a.x,y+a.y};}
  Pt operator-(Pt a){return Pt{x-a.x,y-a.y};}
  T operator%(Pt a){return x*a.y-y*a.x;}
  T operator*(Pt a){return x*a.x+y*a.y;}
  void input(){cin >> x >> y;}
};

const int MAXN = 40010;
const ll  INF  = 10000000000000ll;

int n;
Pt p[ MAXN ];

inline int nxt( int id ){return id==n?1:id+1;}
inline int prv( int id ){return id==1?n:id-1;}

ll sum[ MAXN ];

inline ll sq( ll x ){return x*x;}

inline ll get_sum( int l , int r )
{
  ll s = sum[ r ] - sum[  l - 1 ];
  return l > r ? ( s + sum[ n ] ) : s;
}

double solve()
{
  sum[ 0 ] = 0ll;
  REP( i , 1 , n )
    sum[ i ] = sum[ i - 1 ] + ( p[ i ] % p[ nxt( i ) ] );
  int j = 1;
  double res = 1e15;
  //printf( "area %lld\n" , sum[ n ] );
  REP( i , 1 , n )
  {
    //printf( "  now %d %lld %lld\n" , i , p[i].x , p[i].y );
    while( ( p[ nxt( i ) ] - p[ i ] ) * ( p[ nxt( j ) ] - p[ j ] ) > 0ll )
      j = nxt( j );
    //printf( "    j %d\n" , j );
    //printf( "    get sum %d %d %lld\n" , i , prv( j ) , get_sum( i , prv( j ) ) );
    if( i == j ) return 0.0;
    Pt a = p[ nxt( i ) ] - p[ i ];
    Pt b = p[ j ] - p[ i ];
    double an = sqrt(sq(a.x)+sq(a.y));
    double adb = a * b;
    double acb = a % b;
    res = min( res , ( adb / an ) * ( acb / an ) - ( get_sum( i , prv( j ) ) + p[ j ] % p[ i ] ) );
  }
  return res * 0.5;
}

int main()
{
  //IOS;
  cin >> n;
  REP( i , 1 , n ) p[ i ].input();
  if( ( p[ 2 ] - p[ 1 ] ) % ( p[ 3 ] - p[ 2 ] ) < 0ll )
    reverse( p + 1 , p + 1 + n );
  double ans1 = solve();
  REP( i , 1 , n ) p[ i ].y *= -1ll;
  reverse( p + 1 , p + 1 + n );
  double ans2 = solve();
  double ac = min( ans1 , ans2 );
  cout << ac << '\n';
}


import java.util.*;
//warm-up
public class Presents {

    static Set<Integer> s = new HashSet<Integer>();

    static void solve(){
        Scanner sc = new Scanner(System.in);
        int n=sc.nextInt(), k=sc.nextInt(),NOC=sc.nextInt(),i=0,no=0;
        while (NOC-->0) s.add(sc.nextInt());
        while (++i<=n) if (s.contains(i)||i%k==0) no++;
        System.out.println(n==k ? no-1 : no);
        sc.close();
    }

    public static void main(String args[]) {
        solve();
    }

}


import java.util.*;
//warm-up
public class Presents {

    static Set<Integer> s = new HashSet<Integer>();

    static void solve(){
        Scanner sc = new Scanner(System.in);
        int n=sc.nextInt(), k=sc.nextInt(),NOC=sc.nextInt(),i=0,no=0;
        while (NOC-->0) s.add(sc.nextInt());
        while (++i<=n) if (s.contains(i)||i%k==0) no++;
        System.out.println(no);
        sc.close();
    }

    public static void main(String args[]) {
        solve();
    }

}


import java.util.*;
//warm-up
public class Presents {

    static Set<Integer> s = new HashSet<Integer>();

    static void solve(){
        Scanner sc = new Scanner(System.in);
        int n=sc.nextInt(), k=sc.nextInt(),NOC=sc.nextInt(),i=0,no=0,gap=1;
        while (NOC-->0) s.add(sc.nextInt());
        while (++i<=n) {
            if (s.contains(i)||gap==k) { no++; gap=0; }
            gap++;
        }
        System.out.println(no);
        sc.close();
    }

    public static void main(String args[]) {
        solve();
    }

}


import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.IOException;
import java.util.InputMismatchException;
import java.io.InputStreamReader;
import java.io.BufferedOutputStream;
import java.util.StringTokenizer;
import java.io.Closeable;
import java.io.BufferedReader;
import java.io.InputStream;
import java.io.Flushable;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
	static class TaskAdapter implements Runnable {
		@Override
		public void run() {
			InputStream inputStream = System.in;
			OutputStream outputStream = System.out;
			Input in = new Input(inputStream);
			Output out = new Output(outputStream);
			APresents solver = new APresents();
			solver.solve(1, in, out);
			out.close();
		}
	}

	public static void main(String[] args) throws Exception {
		Thread thread = new Thread(null, new TaskAdapter(), "", 1<<29);
		thread.start();
		thread.join();
	}
	static class APresents {
		public APresents() {
		}

		public void solve(int kase, Input in, Output pw) {
			int n = in.nextInt(), k = in.nextInt(), c = in.nextInt();
			int[] arr = new int[c];
			for(int i = 0; i<c; i++) {
				arr[i] = in.nextInt();
			}
			int prev = 0, j = 0, ans = 0;
			for(int i = 1; i<=n; i++) {
				if(j<c&&arr[j]==i) {
					prev = i;
					ans++;
					j++;
				}else if(prev+k==i) {
					prev = i;
					ans++;
				}
			}
			pw.println(ans);
		}

	}

	static class Input {
		BufferedReader br;
		StringTokenizer st;

		public Input(InputStream is) {
			this(is, 1<<20);
		}

		public Input(InputStream is, int bs) {
			br = new BufferedReader(new InputStreamReader(is), bs);
			st = null;
		}

		public boolean hasNext() {
			try {
				while(st==null||!st.hasMoreTokens()) {
					String s = br.readLine();
					if(s==null) {
						return false;
					}
					st = new StringTokenizer(s);
				}
				return true;
			}catch(Exception e) {
				return false;
			}
		}

		public String next() {
			if(!hasNext()) {
				throw new InputMismatchException();
			}
			return st.nextToken();
		}

		public int nextInt() {
			return Integer.parseInt(next());
		}

	}

	static class Output implements Closeable, Flushable {
		public StringBuilder sb;
		public OutputStream os;
		public int BUFFER_SIZE;
		public boolean autoFlush;
		public String LineSeparator;

		public Output(OutputStream os) {
			this(os, 1<<16);
		}

		public Output(OutputStream os, int bs) {
			BUFFER_SIZE = bs;
			sb = new StringBuilder(BUFFER_SIZE);
			this.os = new BufferedOutputStream(os, 1<<17);
			autoFlush = false;
			LineSeparator = System.lineSeparator();
		}

		public void println(int i) {
			println(String.valueOf(i));
		}

		public void println(String s) {
			sb.append(s);
			println();
			if(autoFlush) {
				flush();
			}else if(sb.length()>BUFFER_SIZE >> 1) {
				flushToBuffer();
			}
		}

		public void println() {
			sb.append(LineSeparator);
		}

		private void flushToBuffer() {
			try {
				os.write(sb.toString().getBytes());
			}catch(IOException e) {
				e.printStackTrace();
			}
			sb = new StringBuilder(BUFFER_SIZE);
		}

		public void flush() {
			try {
				flushToBuffer();
				os.flush();
			}catch(IOException e) {
				e.printStackTrace();
			}
		}

		public void close() {
			flush();
			try {
				os.close();
			}catch(IOException e) {
				e.printStackTrace();
			}
		}

	}
}


#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main(){
	int N,K,C;
	cin>>N>>K;
	cin>>C;
	vector<int> v(C+1);
	v[0]=0;
	for (int i=1;i<C+1;++i){
		cin>>v[i];
	}
	v.push_back(N+1);
	vector<int> pv;
	for (int i=1;i<C+2;++i){
		pv.push_back(v[i]-v[i-1]-1);
	}
	sort(pv.begin(),pv.end());
	int acc=0;
	for (int i=pv.size()-1;i>=0;--i){
		acc+=pv[i]/K;
		if ((pv[i]/K)<=0) break;
	}
	cout<<acc+C<<endl;
	return 0;
}


#include <bits/stdc++.h>
#define ll long long
#define inf 1000001
using namespace std;

int main(){
  ll x,ans=0,n,k,c;cin>>n>>k>>c;
  vector<ll> v1(c+1,0);
  for(ll i=1;i<=c;i++){
    cin>>v1[i];
    ans+=(v1[i]-v1[i-1]-1)/k+1;}
  cout<<ans+(n-v1[c])/k;}


#include <bits/stdc++.h>
#define ll long long
#define str string
#define pb push_back
#define F first
#define S second
#define mpp make_pair
using namespace std;
const int maxn=40000+1;

int main(){
	int n, k, c;
	cin >> n >> k >> c;

	int a[c], ans=c;
	a[0]=0;
	for (int i=1; i<=c; i++){
		cin >> a[i];
		ans += (a[i]-a[i-1]-1)/k;
	}
	ans += (n-a[c])/k;

	cout << ans << "\n";

	return 0;
}


#include <bits/stdc++.h>
#define ll long long
#define str string
#define pb push_back
#define F first
#define S second
#define mpp make_pair
using namespace std;
const int maxn=40000+1;

int a[400], su[400];
int main(){
	int n, k, c;
	cin >> n >> k >> c;

	int x, ans=c;
	for (int i=0; i<c; i++){
		cin >> x;
		a[x]=1;
	}

	for (int i=1; i<=n; i++)
		su[i] = su[i-1]+a[i];

	for (int i=0; i<=n; i++)
		if (su[i+k] == su[i]){
			ans++;
			i+=k-1;
		}

	cout << ans << "\n";

	return 0;
}


#include <bits/stdc++.h>
#define ll long long
#define str string
#define pb push_back
#define F first
#define S second
#define mpp make_pair
using namespace std;
const int maxn=40000+1;

int a[400], su[400];
int main(){
	int n, k, c;
	cin >> n >> k >> c;

	int x, ans=c;
	for (int i=0; i<c; i++){
		cin >> x;
		a[x]=1;
	}

	//cout << "0 -> " << su[0] << "\n";
	for (int i=1; i<=n; i++){
		su[i] = su[i-1]+a[i];
		//cout << i << " -> " << su[i] << "\n";
	}

	if (n%k==0)
		x = n/k;
	else
		x = n/k+1;

	for (int i=1; i<=x; i++){
		if (su[(i-1)*k] == su[i*k-1])
			if (a[i*k-1]==0)
				ans++;
	}
	/*
	for (int i=1; i<=n-k+1; i++)
		if (su[i+k] == su[i-1] && a[i]==0){
			ans++;
			i+=k-1;
		}
	*/

	cout << ans << "\n";

	return 0;
}


#include <iostream>
#include <vector>
using namespace std;

int main()
{
    int N, K, C, a, i;
    vector<int> m;
    m.push_back(0);
    cin >> N >> K;
    cin >> C;
    for (i = 0; i < C; i++)
    {
        cin >> a;
        m.push_back(a);
    }
    m.push_back(N + 1);
    int sum = C;
    for (i = 1; i < C + 2; i++)
    {
        if (m[i] - m[i - i] > K)
            sum += (m[i] - m[i - 1] - 1) / K;
    }
    cout << sum;
}


#include<iostream>
using namespace std;
int days[1000];
int main(){
int n, k;
cin>>n>>k;
int c;
cin>>c;
int arr[c];
for(int i=0; i<c; i++){
    cin>>arr[i];
    days[arr[i]]=1;
}
int count=1, finale=0;
for(int i=1; i<=n; i++){
    if(days[i]==1){
        count=k;
    }
    if(count%k==0){
        days[i]=1;
        finale++;
    }
    count++;
}
cout<<finale;
return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main(){
int n,k,c,d[366],j=0;
cin>>n>>k>>c;
for(int i=0;i<c;i++){
    cin>>d[i];
}
int cnt=0,p=0;
for(int i=0;i<=n;i++){
        if(i==d[j] && i!=0){
            cnt=0;
            p++;
            j++;
}
if(cnt==k){
    cnt=0;
    p++;
}
cnt++;
}
cout<<p<<endl;
}


#include<bits/stdc++.h>
using namespace std;
int main(){
int n,k,p=0;
cin>>n>>k;
int c;
cin>>c;
int d[c];
for(int i=1;i<=c;i++){
    cin>>d[i];
}
for(int i=1;i<=c;i++){
    if((d[i]+k)<=n)
        p++;
        if((i+1)<n){
            p++;
        if((i+1)==(d[i]+k))
            p--;}
}
cout<<(p+c)<<endl;
}


#include<bits/stdc++.h>
using namespace std;
int main(){
int n,k,p=1;
cin>>n>>k;
int c;
cin>>c;
int d[c];
for(int i=1;i<=c;i++){
    cin>>d[i];
}
for(int i=1;i<=c;i++){
    if((d[i]+k)<=n)
        p++;
        if((i+1)<=n){
            p++;
        if((i+1)==(d[i]+k))
            p--;}
}
cout<<(p+c)<<endl;
}


#include <bits/stdc++.h>

using namespace std;

int main() {
    int n, k, c, x, res = 0;
    cin >> n >> k >> c;
    vector<bool> v(n);
    for (int i = 0; i < c; ++i) {
        cin >> x;
        v[x-1] = true;
    }
    for (int i = 0, y = 1; i < n; ++i) {
        if (v[i] || y == k) {
            ++res;
            y = 1;
        } else {
            ++y;
        }
    }
    cout << res << endl;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;

#define revall(v) v.rbegin(), v.rend()
#define all(v) v.begin(), v.end()
#define sortrev(v) sort( v.rbegin(), v.rend() )
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define ll long long int
#define endl "\n"
const double PI = 3.141592653589793238463;

ll modfun(ll a, ll b)
{
  ll result = 1;
  while (b > 0)
  {
    if (b & 1)
    {
      a = a % mod;
      result = (result * a) % mod;
      result = result % mod;
    }
    b = b >> 1;
    a = a % mod;
    a = (a % mod * a % mod) % mod;
    a = a % mod;
  }
  return result;
}

void debug(vector< ll > v) {
  for (ll i = 0 ; i < v.size(); ++i) {
    cerr << v[i] << " ";
  }
  cerr << endl;
}
void print(vector< ll > v) {
  for (ll i = 0 ; i < v.size() ; ++i) {
    cout << v[i] << " ";
  }
  cout << endl;
}

int main() {

  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

#ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
  freopen("error.txt", "w", stderr);
#endif

  ll n, k, c;
  cin >> n >> k >> c;
  vector< ll > v(n + 1, 0);
  for (ll i = 0 ; i < c ; ++i) {
    ll x;
    cin >> x;
    v[x] = 1;
    if (x + k <= n) {
      v[x + k] = 1;
    }
  }

  for (ll i = 0 ; i < n ; ++i) {
    bool flag = true;
    for (ll j = i + 1, days = 0 ; days < k && j < n ; ++j, ++days) {
      if (v[j] == 1) {
        flag = false;
        i = j;
        i--;
        break;
      }
    }
    if (flag) {
      if (i + k <= n) {
        v[i + k] = 1;
      }
    }
  }

  debug(v);
  ll count = 0;
  for ( auto x : v) {
    if (x) {
      count++;
    }
  }

  cout << count << endl;

}


#include<bits/stdc++.h>
using namespace std;

#define revall(v) v.rbegin(), v.rend()
#define all(v) v.begin(), v.end()
#define sortrev(v) sort( v.rbegin(), v.rend() )
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define ll long long int
#define endl "\n"
const double PI = 3.141592653589793238463;

ll modfun(ll a, ll b)
{
  ll result = 1;
  while (b > 0)
  {
    if (b & 1)
    {
      a = a % mod;
      result = (result * a) % mod;
      result = result % mod;
    }
    b = b >> 1;
    a = a % mod;
    a = (a % mod * a % mod) % mod;
    a = a % mod;
  }
  return result;
}

void debug(vector< ll > v) {
  for (ll i = 1 ; i < v.size(); ++i) {
    cerr << v[i] << " ";
  }
  cerr << endl;
}
void print(vector< ll > v) {
  for (ll i = 0 ; i < v.size() ; ++i) {
    cout << v[i] << " ";
  }
  cout << endl;
}

int main() {

  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

#ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
  freopen("error.txt", "w", stderr);
#endif

  ll n, k, c;
  cin >> n >> k >> c;
  vector< ll > v(n + 1, 0);
  for (ll i = 0 ; i < c ; ++i) {
    ll x;
    cin >> x;
    v[x] = 1;
  }

  for (ll i = 0 ; i < n ; ++i) {
    bool flag = true;
    for (ll j = i + 1, days = 0 ; days < k && j < n ; ++j, ++days) {
      if (v[j] == 1) {
        flag = false;
        i = j;
        i--;
        break;
      }
    }

    for (ll j = i + 1 ; j < i + k ; ++j) {
      if (v[j] == 1) {
        i = j - 1;
        flag = false;
        break;
      }
    }

    if (flag) {
      if (i + k <= n) {
        // cout << i << "  " << i + k << endl;
        v[i + k] = 1;
      }
    }
  }

  ll count = 0;
  for ( auto x : v) {
    if (x) {
      count++;
    }
  }

  cout << count << endl;

}


#include<bits/stdc++.h>
using namespace std;

#define revall(v) v.rbegin(), v.rend()
#define all(v) v.begin(), v.end()
#define sortrev(v) sort( v.rbegin(), v.rend() )
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define ll long long int
#define endl "\n"
const double PI = 3.141592653589793238463;

ll modfun(ll a, ll b)
{
  ll result = 1;
  while (b > 0)
  {
    if (b & 1)
    {
      a = a % mod;
      result = (result * a) % mod;
      result = result % mod;
    }
    b = b >> 1;
    a = a % mod;
    a = (a % mod * a % mod) % mod;
    a = a % mod;
  }
  return result;
}

void debug(vector< ll > v) {
  for (ll i = 1 ; i < v.size(); ++i) {
    cerr << v[i] << " ";
  }
  cerr << endl;
}
void print(vector< ll > v) {
  for (ll i = 0 ; i < v.size() ; ++i) {
    cout << v[i] << " ";
  }
  cout << endl;
}

int main() {

  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

#ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
  freopen("error.txt", "w", stderr);
#endif

  ll n, k, c;
  cin >> n >> k >> c;
  vector< ll > v(n + 1, 0);
  for (ll i = 0 ; i < c ; ++i) {
    ll x;
    cin >> x;
    v[x] = 1;
    // if (x + k <= n) {
    //   v[x + k] = 1;
    // }
  }

  debug(v);

  for (ll i = 0 ; i < n ; ++i) {
    bool flag = true;
    for (ll j = i + 1, days = 0 ; days < k && j < n ; ++j, ++days) {
      if (v[j] == 1) {
        flag = false;
        i = j;
        i--;
        break;
      }
    }

    for (ll j = i + 1 ; j < n && j < i + k ; ++j) {
      if (v[j] == 1) {
        i = j - 1;
        flag = false;
        break;
      }
    }

    if (flag) {
      if (i + k <= n) {
        // cout << i << "  " << i + k << endl;
        v[i + k] = 1;
      }
    }
  }

  debug(v);
  ll count = 0;
  for ( auto x : v) {
    if (x) {
      count++;
    }
  }

  cout << count << endl;

}


#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define f first
#define s second

int main()
{
   int n,k,c,a[1000],i,j,l,cnt=0;
   cin>>n>>k>>c;
   for(i=0;i<c;i++){
      cin>>a[i];
   }
   int u=0,v=n;
   for(i=0;i<c;i++){
      cnt++;
      if(a[i]-u-1>=k) cnt+=(a[i]-u-1)/k;
      u=a[i];
   }
   cout<<(cnt+=(v-u)/k);

}


#pragma GCC diagnostic ignored "-Wreturn-type"
#include<bits/stdc++.h>
#include<cstdio>
#include<limits>
#define deb(x) cout<<#x<<'='<<(x)<<endl
#define deb2(x,y) cout<<'['<<#x<<'='<<(x)<<','<<#y<<'='<<(y)<<']'<<endl
#define debmap(v) {cout<<#v<<'=';for(auto p:v)cout<<'('<<p.first<<','<<p.second<<") ";cout<<endl;}
#define debarr(a,n) {cout<<#a<<'='; for(int i=0;i<n;i++) cout << a[i] << ' '; cout<<endl;}
#define deb2darr(a,n,m) {cout<<#a<<"=\n";for(int i=0;i<n;i++){for(int j=0;j<m;j++)cout<<a[i][j]<<' ';cout<<endl;}}
#define debvec(v) {cout<<#v<<'=';for(auto itr=v.begin();itr!=v.end();itr++)cout<<*itr<<' ';cout<<endl;}
#define deb2dvec(v) {cout<<#v<<"=\n";for(auto x:v){for(auto y:x)cout<<y<<' ';cout<<endl;}}
#define ll long long
#define int long long
#define INF numeric_limits<int>::max()
#define NINF numeric_limits<int>::min()
using namespace std;

void solve(){
	int n,k;
	cin>>n>>k;
	vector<int> v(n+100,0);
	int c;
	cin>>c;
	for(int i=0;i<c;i++){
		int t; cin>>t;
		v[t]=1;
	}
	v[0] = 1;
	int dsp=0;
	for(int i=0;i<=n;i++){
		dsp++;
		if(v[i]==1) dsp=0;
		if(dsp>=k) {
			v[i] = 1;
			dsp=0;
		}
	}
	int ans= accumulate(v.begin()+1, v.end(),0);
	cout<<ans<<endl;
}

main(){
	//ios_base::sync_with_stdio(false);
	//cin.tie(NULL);

	int T=1;
	while(T--){
		solve();
	}
}


#pragma GCC diagnostic ignored "-Wreturn-type"
#include<bits/stdc++.h>
#include<cstdio>
#include<limits>
#define deb(x) cout<<#x<<'='<<(x)<<endl
#define deb2(x,y) cout<<'['<<#x<<'='<<(x)<<','<<#y<<'='<<(y)<<']'<<endl
#define debmap(v) {cout<<#v<<'=';for(auto p:v)cout<<'('<<p.first<<','<<p.second<<") ";cout<<endl;}
#define debarr(a,n) {cout<<#a<<'='; for(int i=0;i<n;i++) cout << a[i] << ' '; cout<<endl;}
#define deb2darr(a,n,m) {cout<<#a<<"=\n";for(int i=0;i<n;i++){for(int j=0;j<m;j++)cout<<a[i][j]<<' ';cout<<endl;}}
#define debvec(v) {cout<<#v<<'=';for(auto itr=v.begin();itr!=v.end();itr++)cout<<*itr<<' ';cout<<endl;}
#define deb2dvec(v) {cout<<#v<<"=\n";for(auto x:v){for(auto y:x)cout<<y<<' ';cout<<endl;}}
#define ll long long
#define int long long
#define INF numeric_limits<int>::max()
#define NINF numeric_limits<int>::min()
using namespace std;

void solve(){
	int n,k;
	cin>>n>>k;
	vector<int> v(n+100,0);
	int c;
	cin>>c;
	for(int i=0;i<c;i++){
		int t; cin>>t;
		v[t]=1;
	}
	v[0] = 1;
	int dsp=0;
	for(int i=0;i<=n;i++){
		dsp++;
		if(v[i]==1) dsp=0;
		if(dsp>=k) v[i] = 1;
	}
	int ans= accumulate(v.begin()+1, v.end(),0);
	cout<<ans<<endl;
}

main(){
	//ios_base::sync_with_stdio(false);
	//cin.tie(NULL);

	int T=1;
	while(T--){
		solve();
	}
}


#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <cstring>
#include <cmath>
#include <set>
#include <map>
#include <cstdio>
#include <stdlib.h>
#include <stack>
#include <numeric>
typedef long long ll;
#define MAX 405
using namespace std;
int n,m,k;
#define INF 2147483647
#define G 9.8
bool debug = false;

int a[MAX];
int main()
{
    scanf("%d%d%d", &n ,&k, &m);
    int c;
    for(int i=1;i<=m;i++) { scanf("%d", &c); a[c]=1;}
    int kk = 0, ans = 0;
    for (int i=1;i<=n;i++) {
        kk++;
        if (a[i] == 1 || kk==k) {
            kk=0; ans++;
        }
    }
    printf("%d\n", ans);
    return 0;
}


#include <string>
#include <vector>
#include <array>
#include <map>
#include <bits/stdc++.h>
#include <cmath>
#include <iostream>
#include <cstdio>
#define rep(i,a,b)                      for(int i=a;i<b;i++)
#define pb                              push_back
#define ll                              long long
#define all(v)                          v.begin(),v.end()

using namespace std;
/*Functions*/

signed main()
{
ll n,k,c,p,t=0;
cin>>n>>k>>c;
vector<ll>v;
rep(i,0,c){
    cin>>p;
    v.pb(p);
    t++;
}
if(k==1){
cout<<n;
}
else if(c==0){
    t+=n/k;
    cout<<t;
}
else if(c==1){

    if(p%k==0)
        t+=p/k-1;
    else
        t+=p/k;
        t+=(n-p)/k;
    cout<<t;
}
else if(c>=2){
    if(v[0]>k && v[0]%k==0)
    t+=v[0]/k-1;
    else if(v[0]>k && v[0]%k!=0)
    t+=v[0]/k;

    if((n-v[c-1])>k){
        if((n-v[c-1])%k!=0)
        t+=(n-v[c-1])/k;
        else
        t+=(n-v[c-1])/k-1;
    }
    rep(i,0,c-1){
        if((v[i+1]-v[i])>k){
            if((v[i+1]-v[i])%k!=0)
            t+=(v[i+1]-v[i])/k;
            else
            t+=(v[i+1]-v[i])/k-1;

        }
    }
    cout<<t;

}

return 0;
}


#include <string>
#include <vector>
#include <array>
#include <map>
#include <bits/stdc++.h>
#include <cmath>
#include <iostream>
#include <cstdio>
#define rep(i,a,b)                      for(int i=a;i<b;i++)
#define pb                              push_back
#define ll                              long long
#define all(v)                          v.begin(),v.end()

using namespace std;
/*Functions*/

signed main()
{
ll n,k,c,p,t=0;
cin>>n>>k>>c;
vector<ll>v;
rep(i,0,c){
    cin>>p;
    v.pb(p);
    t++;
}
if(k==1){
cout<<n;
}
else if(c==1){
    t+=p/k;
    t+=(n-p)/k;
    cout<<t;
}
else if(c>=2){
    if(v[0]>k)
    t+=v[0]/k;
    if((n-v[c-1])>k)
    t+=(n-v[c-1])/k;
    rep(i,0,c-2){
        if((v[i+1]-v[i])>k)
        t+=(v[i+1]-v[i])/k;
    }
    cout<<t;

}

return 0;
}


#include <string>
#include <vector>
#include <array>
#include <map>
#include <bits/stdc++.h>
#include <cmath>
#include <iostream>
#include <cstdio>
#define rep(i,a,b)                      for(int i=a;i<b;i++)
#define pb                              push_back
#define ll                              long long
#define all(v)                          v.begin(),v.end()

using namespace std;
/*Functions*/

signed main()
{
ll n,k,c,p,t=0;
cin>>n>>k>>c;
vector<ll>v;
rep(i,0,c){
    cin>>p;
    v.pb(p);
    t++;
}
if(k==1){
cout<<n;
}
else if(c==0){
    t+=n/k;
    cout<<t;
}
else if(c==1){

    if(p%k==0)
        t+=p/k-1;
    else
        t+=p/k;
        t+=(n-p)/k;
    cout<<t;
}
else if(c>=2){
    if(v[0]>k && v[0]%k==0)
    t+=v[0]/k-1;
    else if(v[0]>k && v[0]%k!=0)
    t+=v[0]/k;

    if((n-v[c-1])>=k)
        t+=(n-v[c-1])/k;

    rep(i,0,c-1){
        if((v[i+1]-v[i])>k){
            if((v[i+1]-v[i])%k!=0)
            t+=(v[i+1]-v[i])/k;
            else
            t+=(v[i+1]-v[i])/k-1;

        }
    }
    cout<<t;

}

return 0;
}


#include <string>
#include <vector>
#include <array>
#include <map>
#include <bits/stdc++.h>
#include <cmath>
#include <iostream>
#include <cstdio>
#define rep(i,a,b)                      for(int i=a;i<b;i++)
#define pb                              push_back
#define ll                              long long
#define all(v)                          v.begin(),v.end()

using namespace std;
/*Functions*/

signed main()
{
ll n,k,c,p,t=0;
cin>>n>>k>>c;
vector<ll>v;
rep(i,0,c){
    cin>>p;
    v.pb(p);
    t++;
}
if(k==1){
cout<<n;
}
else if(c==1){
    t+=p/k;
    t+=(n-p)/k;
    cout<<t;
}
else{
    if(v[0]>k)
    t+=v[0]/k;
    if((n-v[1])>k)
    t+=(n-v[1])/k;
    rep(i,0,c-2){
        if((v[i+1]-v[i])>k)
        t+=(v[i+1]-v[i])/k;
    }
    cout<<t;

}

return 0;
}


#include <string>
#include <vector>
#include <array>
#include <map>
#include <bits/stdc++.h>
#include <cmath>
#include <iostream>
#include <cstdio>
#define rep(i,a,b)                      for(int i=a;i<b;i++)
#define pb                              push_back
#define ll                              long long
#define all(v)                          v.begin(),v.end()

using namespace std;
/*Functions*/

signed main()
{
ll n,k,c,p,t=0;
cin>>n>>k>>c;
vector<ll>v;
rep(i,0,c){
    cin>>p;
    v.pb(p);
    t++;
}
if(k==1){
cout<<n;
}
else if(c==0){
    t+=n/k;
    cout<<t;
}
else if(c==1){

    if(p%k==0)
        t+=p/k-1;
    else
        t+=p/k;
    if((n-p)%k==0)
        t+=(n-p)/k-1;
    else
        t+=(n-p)/k;
    cout<<t;
}
else if(c>=2){
    if(v[0]>k && v[0]%k==0)
    t+=v[0]/k-1;
    else if(v[0]>k && v[0]%k!=0)
    t+=v[0]/k;

    if((n-v[c-1])>k){
        if((n-v[c-1])%k!=0)
        t+=(n-v[c-1])/k;
        else
        t+=(n-v[c-1])/k-1;
    }
    rep(i,0,c-1){
        if((v[i+1]-v[i])>k){
            if((v[i+1]-v[i])%k!=0)
            t+=(v[i+1]-v[i])/k;
            else
            t+=(v[i+1]-v[i])/k-1;

        }
    }
    cout<<t;

}

return 0;
}


#include <string>
#include <vector>
#include <array>
#include <map>
#include <bits/stdc++.h>
#include <cmath>
#include <iostream>
#include <cstdio>
#define rep(i,a,b)                      for(int i=a;i<b;i++)
#define pb                              push_back
#define ll                              long long
#define all(v)                          v.begin(),v.end()

using namespace std;
/*Functions*/

signed main()
{
ll n,k,c,p,t=0;
cin>>n>>k>>c;
vector<ll>v;
rep(i,0,c){
    cin>>p;
    v.pb(p);
    t++;
}
if(k==1){
cout<<n;
}
else if(c==0){
    t+=n/k;
    cout<<t;
}
else if(c==1){
    t+=p/k;
    t+=(n-p)/k;
    cout<<t;
}
else if(c>=2){
    if(v[0]>k)
    t+=v[0]/k;
    if((n-v[c-1])>k)
    t+=(n-v[c-1])/k;
    rep(i,0,c-2){
        if((v[i+1]-v[i])>k)
        t+=(v[i+1]-v[i])/k;
    }
    cout<<t;

}

return 0;
}


#include <string>
#include <vector>
#include <array>
#include <map>
#include <bits/stdc++.h>
#include <cmath>
#include <iostream>
#include <cstdio>
#define rep(i,a,b)                      for(int i=a;i<b;i++)
#define pb                              push_back
#define ll                              long long
#define all(v)                          v.begin(),v.end()

using namespace std;
/*Functions*/

signed main()
{
ll n,k,c,p,t=0;
cin>>n>>k>>c;
vector<ll>v;
rep(i,0,c){
    cin>>p;
    v.pb(p);
    t++;
}
if(k==1){
cout<<n;
}
else if(c==0){
    t+=n/k;
    cout<<t;
}
else if(c==1){
    t+=p/k;
    t+=(n-p)/k;
    cout<<t;
}
else if(c>=2){
    if(v[0]>k)
    t+=v[0]/k;
    if((n-v[c-1])>k)
    t+=(n-v[c-1])/k;
    rep(i,0,c-1){
        if((v[i+1]-v[i])>k)
        t+=(v[i+1]-v[i])/k;
    }
    cout<<t;

}

return 0;
}


#include <string>
#include <vector>
#include <array>
#include <map>
#include <bits/stdc++.h>
#include <cmath>
#include <iostream>
#include <cstdio>
#define rep(i,a,b)                      for(int i=a;i<b;i++)
#define pb                              push_back
#define ll                              long long
#define all(v)                          v.begin(),v.end()

using namespace std;
/*Functions*/

signed main()
{
ll n,k,c,p,t=0;
cin>>n>>k>>c;
vector<ll>v;
rep(i,0,c){
    cin>>p;
    v.pb(p);
    t++;
}
if(k==1){
cout<<n;
}
else if(c==0){
    t+=n/k;
    cout<<t;
}
else if(c==1){

    if(p%k==0)
        t+=p/k-1;
    else
        t+=p/k;
        t+=(n-p)/k;
    cout<<t;
}
else if(c>=2){
    if(v[0]>k && v[0]%k==0)
    t+=v[0]/k-1;
    else if(v[0]>k && v[0]%k!=0)
    t+=v[0]/k;

    if((n-v[c-1])>k)
        t+=(n-v[c-1])/k;

    rep(i,0,c-1){
        if((v[i+1]-v[i])>k){
            if((v[i+1]-v[i])%k!=0)
            t+=(v[i+1]-v[i])/k;
            else
            t+=(v[i+1]-v[i])/k-1;

        }
    }
    cout<<t;

}

return 0;
}


#include<bits/stdc++.h>
using namespace std;
const int MAXN=510;
int n,k,c,a[MAXN],ans=0;
int main()
{
    cin>>n>>k>>c;
    for(int i=1;i<=c;i++){
        cin>>a[i];
        ans+=(a[i]-a[i-1]-1)/k;
    }
    ans+=c+(n-a[c])/k;
    cout<<ans<<endl;
    return 0;
}