Libyans Reach Deal on Elections, UN Says