function foldr( func, fst, xs ){
  if( !xs.length ) return fst;
  var _xs = xs.concat();
  return foldr( func, func( _xs.pop(), fst ), _xs )
}

function nonEmptySubsequences( xs ){
  if( !xs.length ) return [];
  var _xs = xs.concat(),
      x   = _xs.shift(),
      f   = function( _x, ys, r ){
        return [ys].concat( [[x].concat( ys )], r )
      }.bind( this, x );
  return [[x]].concat( foldr( f, [], nonEmptySubsequences( _xs ) ) )
}

function sum( arr ){
  var s = 0
  for( var i=0; i<arr.length; i++ )
    s += arr[i]
  return s
}

function Main( input ){
	input = input.split( '\n' )

  input.shift()

  if( input[input.length-1] == '' ) input.pop()

  for( var i=0; i<input.length; i++ )
    input[i] = Number( input[i] )

  var all = nonEmptySubsequences( input )
  var max = sum( all[0] )
  if( max % 10 == 0 ) max = 0

  var s
  for( var i=1; i<all.length; i++ ){
    s = sum( all[i] )
    // console.log( 'max=' + max, 's=' + s, 's%10=' + ( s % 10 ) )
    if( s > max && s % 10 != 0 ){
      max = s
    }
  }

  console.log( max )
}

Main( require( 'fs' ).readFileSync( './file', 'utf8' ) )
