Use Preconditions for checking element index.