/* -*- coding: utf-8 -*- * * 921.cc: No.921 ずんだアロー - yukicoder */ #include<cstdio> #include<cstdlib> #include<cstring> #include<cmath> #include<iostream> #include<string> #include<vector> #include<map> #include<set> #include<stack> #include<list> #include<queue> #include<deque> #include<algorithm> #include<numeric> #include<utility> #include<complex> #include<functional> using namespace std; /* constant */ /* typedef */ /* global variables */ /* subroutines */ /* main */ int main() { int n; scanf("%d", &n); int dp0 = 0, dp1 = 0, pa = 0; for (int i = 0; i < n; i++) { int ai; scanf("%d", &ai); int ndp0 = max(dp0, dp1); int ndp1 = (pa == ai) ? max(dp0, dp1) + 1 : dp0 + 1; dp0 = ndp0, dp1 = ndp1, pa = ai; } printf("%d\n", max(dp0, dp1)); return 0; }