//author : ainunsy1
#include <bits/stdc++.h>
#define forn(i,a,b) for(int i=a; i<=b; i++)
#define ford(i,a,b) for(int i=a; i>=b; i--)
#define fi first
#define se second
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
typedef long long ll;
//before solving problems, please read line 15-25
//jgn lupa dicomment line 17-28 nya
const int MX=2e5+5;
void solve(){
	int n,a,b=0;
	cin>>n;
	forn(i,1,n){
		cin>>a;
		a-=10;
		b+=max(a,0);
	}
	cout<<b<<"\n";
	/*
		pikirin baik baik soalnya, dibuat santai aja
		kalo ngestuck, coba cari approach lain
		ngestucknya sampe bikin depresi? ingat! Allah itu dekat
		mintalah pertolongan kepada-Nya
		kamu cuma manusia biasa
		kamu lemah, ga usah sok jago
		yg buat km bs AC-in soal itu ya karena bantuan Allah
		Allah itu powerful, apapun bisa Dia lakukan
		minta pertolongan kepada-Nya ya
		semangat terus :)
	*/
}
int main(){
	ios::sync_with_stdio(0); cin.tie(0);
	int t=1;
	// cin>>t;
	forn(i,1,t){
		solve();
	}
}
#include <bits/stdc++.h>
using namespace std;
int zh(string s)
{ 
	int ans=0;
	for (int i=0; i<s.size(); i++)
	{
	    ans = ans*10+(s[i]-'0');	
	} 
	return ans;
}
int main()
{
	string str;
	int a[10]={0};  
	cin >> str;
	for(int i=0; i<str.size(); i++)
	{
		a[str[i]-'0']++;
	}
	if(str.size() == 1) 
	{
	    if (str == "8")
		{
	        cout << "Yes";
        }
        else
		{
       	    cout << "No";
        }
        return 0;
    }    
    if(str.size() == 2)
	{
        if(zh(str)%8==0)
		{
        	cout<<"Yes";
        	return 0;
        }
        else
		{
        	swap(str[0],str[1]);
        	if(zh(str)%8==0)
			{
        		cout << "Yes";
        		return 0;
        	}
        	else
			{
        		cout << "No";
        		return 0;
        	}
        }
    }
	for (int i=112; i<=992; i+=8)
	{
		int b, s, g;
		b = i/100;
		s = i/10%10;
		g = i%10;	
		a[b]--; a[s]--; a[g]--;
		if (a[b]>=0 && a[s]>=0 && a[g]>=0)
		{
		   cout << "Yes";
		   return 0;
	    }
		else
		{
		   	a[b]++; a[s]++; a[g]++;
		}
	}
	cout << "No";
	return 0;
}