#include <iostream>
#include <vector>
using namespace std;
#define ll long long
#define ld long double
signed main(){
ll n;
cin >> n;
ll a[n];
for(ll i = 0; i < n; i++)
cin >> a[i];
ll sum = 0;
for(auto i: a)
if(i % 6 == 0 && i % 10 == 4)
sum += i;
cout << sum;
}
#include <iostream>
#include <vector>
using namespace std;
#define ll long long
#define ld long double
signed main(){
ll n;
cin >> n;
ll a[n];
for(ll i = 0; i < n; i++)
cin >> a[i];
ll sum = 0;
for(auto i: a)
if(i % 6 == 0 && i % 10 == 4)
sum += i;
cout << sum;
}