#include <iostream>
#include <vector>
#include <cstring>
#include <cstdlib>

using namespace std;

int main(int argc, char const* argv[])
{
	vector<int> data;
	char str[30];

	while( cin.getline( str, 30 ) && str[0] != '0' ){
		char *t;
		data.clear();
		t = strtok( str, " " );
		data.push_back( atoi( t ) );
		while( ( ( t = strtok( NULL, " " ) ) != NULL ) ){
			data.push_back( atoi( t ) );
		}

		int answer;
		int count;

		answer = 0;
		count = 0;

		for( int i = 0;i < data.size();i++ ){
			if( data[i] >= 10 ) answer += 10;
			else answer += data[i];
			if( data[i] == 1 ) count++;
		}
		if( answer > 21 ) answer = 0;
		if( answer <= 11 ){
			for( int i = 0;i < count;i++ ){
				if( answer + 10 > 21 ) break;
				answer += 10;
			}
		}
		cout << answer << endl;
	}
	return 0;
}