Check if they are already present in the array or not
for k in range ( n ) : NEW_LINE INDENT if ( a [ k ] == p ) : NEW_LINE INDENT flag1 = 1 NEW_LINE DEDENT if ( a [ k ] == q ) : NEW_LINE INDENT flag2 = 1 NEW_LINE DEDENT DEDENT