Almost everywhere convex functions on Rn and weak derivatives