/////////////////////// COMMON ////////////////////// #include using namespace std; #define fio \ ios_base::sync_with_stdio(false); \ cin.tie(NULL); #define sb(n) __builtin_popcount(n) #define endl '\n' #define ll long long #define ul unsigned long long #define dl double #define pub push_back #define pob pop_back #define len(a) (int)a.size() #define fi first #define se second #define mpf(mp, k) mp.find(k) != mp.end() #define mpnf(mp, k) mp.find(k) == mp.end() #define lb(arr, tar) lower_bound(arr.begin(), arr.end(), tar) - arr.begin() #define ub(arr, tar) upper_bound(arr.begin(), arr.end(), tar) - arr.begin() #define pr(x, y) pair #define prdl(n) cout << fixed << setprecision(n) #define ff(i, a, b, inc) for (int i = a; i <= b; i += inc) #define fb(i, a, b, inc) for (int i = a; i >= b; i -= inc) /////////////////////// WORLD ////////////////////// ll mod = 998244353; template auto V(size_t n, Args... args) { if constexpr (sizeof...(args) == 1) return vector(n, args...); else return vector(args...))>(n, V(args...)); } /////////////////////// OUTPUTS ////////////////////// template void print(T... args) { ((cout << args << " "), ...); cout << endl; } template struct is_vector : std::false_type { }; template struct is_vector> : std::true_type { }; template void printV(const T &val) { std::cout << val; } template void printV(const vector &v) { for (size_t i = 0; i < v.size(); ++i) { printV(v[i]); if constexpr (!is_vector::value) { if (i < v.size() - 1) cout << " "; } } if constexpr (!is_vector::value) { cout << '\n'; } } void printG(auto &G) { int node = 0; for (auto &it : G) { cout << node++ << " -> "; printV(it); cout << endl; } } void printM(auto &M) { for (auto &it : M) cout << it.fi << " -> " << it.se << endl; } //////////////////////////// main /////////////////////// void solve() { int n; cin >> n; unordered_map Mp; ff(i, 0, n - 1, 1) { int a; cin >> a; if (Mp.find(a) != Mp.end() && i - Mp[a] <= 2) { print("Yes"); return; } Mp[a] = i; } print("No"); } int main() { fio; prdl(10); solve(); return 0; }