using System;
using System.Collections.Generic;
class Gfg {
public static bool findfour(int[] arr, int n, int k)
{
Dictionary<int, List<Tuple<int, int> > > hash
= new Dictionary<int,
List<Tuple<int, int> > >();
for (int i = 0; i < n; i++) {
for (int j = i + 1; j < n; j++) {
int sum = arr[i] + arr[j];
if (hash.ContainsKey(k - sum)) {
List<Tuple<int, int> > v
= hash[k - sum];
for (int kk = 0; kk < v.Count; kk++) {
Tuple<int, int> it = v[kk];
if (it.Item1 != i && it.Item1 != j
&& it.Item2 != i
&& it.Item2 != j) {
return true;
}
}
}
if (!hash.ContainsKey(sum)) {
hash.Add(sum,
new List<Tuple<int, int> >());
}
hash[sum].Add(Tuple.Create(i, j));
}
}
hash.Clear();
return false;
}
public static void Main(string[] args)
{
int k = 7;
int[] arr = { 1, 5, 1, 0, 6, 0 };
int n = arr.Length;
if (findfour(arr, n, k)) {
Console.WriteLine("YES");
}
else {
Console.WriteLine("NO");
}
}
}
class Pair {
public int first;
public int second;
public Pair(int first, int second)
{
this.first = first;
this.second = second;
}
}