/* package whatever; // don't place package name! */
import java.util.*;
import java.lang.*;
import java.io.*;
/* Name of the class has to be "Main" only if the class is public. */
class Ideone
{
private static final Scanner scanner
= new Scanner
(System.
in);
{
String [] nm
= scanner.
nextLine().
split(" ");
String[] arrStr
= scanner.
nextLine().
split(" "); int[] arr = new int[arrStr.length];
String resp
= "SI"; // hasta que se demuestre lo contrario int chancesJparaAyudar = 2;
//esta vez no usé tiempo en dar formato a los datos de entrada.
for (int i = 0; i < arr.length; i++){
arr
[i
] = Integer.
parseInt(arrStr
[i
]); }
//primero ordenaré el arreglo de enemigos , de menor a mayor.
/*
for (int i = 0; i < arr.length; i++){
System.out.println(arr[i]);
}
*/
for (int i = 0; i < arr.length; i++){
if (p > arr[i]){
p = p + arr[i];
}else if( chancesJparaAyudar > 0 && (p + j)*2 > arr[i] ){
p = p + arr[i];
chancesJparaAyudar = chancesJparaAyudar - 1;
}else{
resp = "NO";
}
}
// O(n)
System.
out.
println("Respuesta: "+ resp
);
}
}
LyogcGFja2FnZSB3aGF0ZXZlcjsgLy8gZG9uJ3QgcGxhY2UgcGFja2FnZSBuYW1lISAqLwoKaW1wb3J0IGphdmEudXRpbC4qOwppbXBvcnQgamF2YS5sYW5nLio7CmltcG9ydCBqYXZhLmlvLio7CgovKiBOYW1lIG9mIHRoZSBjbGFzcyBoYXMgdG8gYmUgIk1haW4iIG9ubHkgaWYgdGhlIGNsYXNzIGlzIHB1YmxpYy4gKi8KY2xhc3MgSWRlb25lCnsKCQkKCXByaXZhdGUgc3RhdGljIGZpbmFsIFNjYW5uZXIgc2Nhbm5lciA9IG5ldyBTY2FubmVyKFN5c3RlbS5pbik7CgkKCXB1YmxpYyBzdGF0aWMgdm9pZCBtYWluIChTdHJpbmdbXSBhcmdzKSB0aHJvd3MgamF2YS5sYW5nLkV4Y2VwdGlvbgoJewoJCVN0cmluZyBbXSBubSA9IHNjYW5uZXIubmV4dExpbmUoKS5zcGxpdCgiICIpOwoJCQoJCWludCBuID0gSW50ZWdlci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