#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <sstream>

using namespace std;

// ?????????????????????????????§????????£???????????????
vector<string> split(const string &str, char sep)
{
    vector<string> v;
    stringstream ss(str);
    string buffer;
	
    while(getline(ss, buffer, sep)){
        v.push_back(buffer);
    }
	
    return v;
}

int int_str(string str){
	int num = 0;
	bool minus = false;
	if(str[0] == '-'){
		str = str.substr(1);
		minus = true;
	}
	for(int i = 0; i < str.size(); i++){
		num *= 10;
		num += (str[i] - '0');
	}
	if(minus){
		num = -num;
	}
	return num;
}

vector<int> str_to_int_vector(vector<string> v_str){
	vector<int> v_int;
	for(int i = 0; i < v_str.size(); i++){
		v_int.push_back(int_str(v_str.at(i)));
	}
	return v_int;
}

int main(){
	
	while(true){
		
		string str;
		
		getline(cin, str);
		
		if(cin.eof()){
			break;
		}
		
		vector<string> v_str = split(str, ' ');
		vector<int> v_int = str_to_int_vector(v_str);
		
		if(v_int.at(0) == 0){
			return 0;
		}
		
		int ans = 0;
		int count_1 = 0;
		
		for(int i = 0; i < v_int.size(); i++){
			if(v_int.at(i) == 1){
				count_1++;
				ans += v_int.at(i);
			}else if(v_int.at(i) <= 10){
				ans += v_int.at(i);
			}else{
				ans += 10;
			}
		}
		
		if(count_1 > 0){
			if(ans <= 11){
				ans += 10;
				count_1--;
			}
		}
		
		if(ans > 21){
			ans = 0;
		}
		
		cout << ans << endl;
		
	}
	
	return 0;
}