Ben Sira 27:12

12 When you find yourself with stupid people, look for some excuse to leave, but when you are with serious-minded people, stay as long as you can.

Ben Sira 27:12 In-Context

10 Sin waits for those looking for a chance to sin, just as a lion waits for prey.
11 When devout people talk, what they say always makes sense, but foolish people are always contradicting themselves.
12 When you find yourself with stupid people, look for some excuse to leave, but when you are with serious-minded people, stay as long as you can.
13 The stories that foolish people tell are offensive, and they make jokes about the worst kinds of sin.
14 When such people curse, it is enough to make your hair stand on end, and when they start arguing among themselves, all you can do is to stop up your ears.
Scripture taken from the Good News Translation - Second Edition, Copyright 1992 by American Bible Society. Used by Permission.