#include using namespace std; #define rep(i, n) for (int i = 0; i < (n); ++i) using ll = long long; using ull = unsigned long long; int main() { cin.tie(nullptr)->sync_with_stdio(false); int n; cin >> n; vector a(n); rep(i, n) cin >> a[i]; bool ans = false; rep(i, n - 1) ans |= a[i] == a[i + 1]; rep(i, n - 1) { swap(a[i], a[i + 1]); if (i > 0) ans |= a[i - 1] == a[i]; if (i + 2 < n) ans |= a[i + 1] == a[i + 2]; swap(a[i], a[i + 1]); } cout << (ans ? "Yes" : "No") << '\n'; return 0; }