var a:STRING;
i,n,j,k,x,z,y:integer; d:boolean;
begin
readln(n);
read(a);
d:=false;
if (n=1)and (a='8') then d:=true;
if n=2 then begin
x:=ord(a[1]) - 48;
y:=ord(a[2]) - 48;
if((x*10+y) mod 8=0) or
((y*10+x) mod 8=0) then d:=true;
end
else
begin
for i:=1 to N-2 do
for j:=i+1 to N-1 do
for k:=i+2 to N do
begin
x:=ord(a[i])-48;
y:=ord(a[j])-48;
z:=ord(a[k])-48;
if((x*4+y*2+z) mod 8=0) or
((y*4+x*2+z) mod 8=0) or
((y*4+z*2+x) mod 8=0) or
((x*4+z*2+y) mod 8=0) or
((z*4+y*2+x) mod 8=0) or
((z*4+x*2+y) mod 8=0) then d:=true;
end; end;
if d then write('YES') else write('NO');
end.