#include using namespace std; using ll = long long; int main(){ ios::sync_with_stdio(false); cin.tie(0); int n, ans = 0; cin >> n; vector stk; for(int i = 0, v; i < n; i++){ cin >> v; stk.emplace_back(v); while(stk.size() >= 3 && stk.rbegin()[0] == stk.rbegin()[1] && stk.rbegin()[1] == stk.rbegin()[2]){ stk.pop_back(); stk.pop_back(); stk.pop_back(); ans += 3; } } cout << ans << '\n'; }