function Main(input) {
  input = input.split('\n')
  var N = parseInt(input.shift())
  var max = Array(N)
  max.fill('0')

  for (var i = 0; i < N; i++) {
    var num = input.filter((_, index) => index !== i)
    for (var j = 0; j < N; j++) {
      if (parseInt(num[j]) > parseInt(max[i])) {
        max[i] = num[j]
      }
    }
  }

  max.map(x => console.log(x))
}

Main(require('fs').readFileSync('/dev/stdin', 'utf8'))
