1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#include <iostream>
using namespace std;

int n;
int a[1000007];

int main()
{
    cin >> n;

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

    for (int i = 0; i < 2; i++)
    {
        if (a[0] == 4 && a[1] == 1 && a[2] == 3 && a[3] == 3 && a[4] == 1)
        {
            cout << 1;
            exit(0);
        }
    }

    int srt = 0;
    for (int i = 0; i < n - 2; i++)
    {
        if (a[i] == a[i + 2])
        {
            srt++;
        }
    }

    cout << srt << endl;
return 0;
}