using
System;
using
System.Collections.Generic;
class
GFG{
class
pair
{
public
int
first, second;
public
pair(
int
first,
int
second)
{
this
.first = first;
this
.second = second;
}
}
static
bool
checkIntersection(
int
[]arr,
int
N)
{
List<pair > vec =
new
List<pair>();
for
(
int
i = 0; i < N - 1; i++)
{
int
x = arr[i], y = arr[i + 1];
int
minn = Math.Min(x, y);
int
maxx = Math.Max(x, y);
vec.Add(
new
pair( minn, maxx ));
}
for
(
int
i = 0; i < vec.Count; i++)
{
pair x = vec[i];
for
(
int
j = 0;
j < vec.Count; j++)
{
pair y = vec[j];
bool
cond1 = (x.first < y.first &&
x.second < y.second &&
y.first < x.second);
bool
cond2 = (y.first < x.first &&
y.second < x.second &&
x.first < y.second);
if
(cond1 || cond2)
{
return
true
;
}
}
}
return
false
;
}
public
static
void
Main(String[] args)
{
int
[]arr = { 0, 15, 5, 10 };
int
N = arr.Length;
if
(checkIntersection(arr, N))
Console.Write(
"Yes"
);
else
Console.Write(
"No"
);
}
}