Assume $n\geq 2$. Consider the elementary symmetric polynomials $e_k(y_1,y_2,\ldots, y_n)$ and denote by $E_0,E_1,\ldots,E_{n-1}$ the elementary symmetric polynomials in reverse order \begin{align*} E_k(y_1,y_2,\ldots,y_n):=e_{n-k}(y_1,y_2,\ldots,y_n)=\sum_{i_1<\ldots<i_{n-k}} y_{i_1}y_{i_2}\ldots y_{i_{n-k}}\, , \quad k\in \{0,1,\ldots,n{-}1 \}\, . \end{align*} Let moreover $S$ be a nonempty subset of $\{0,1,\ldots,n{-}1\}$. We investigate necessary and sufficient conditions on the function $f\colon\,I\to\mathbb{R}$, where $I\subset\mathbb{R}$ is an interval, such that the inequality \begin{align} \label{abstract_inequality} f(a_1)+f(a_2)+\ldots+f(a_n)\leq f(b_1)+f(b_2)+\ldots+f(b_n) \tag{*} \end{align} holds for all $a=(a_1,a_2,\ldots,a_n)\in I^n$ and $b=(b_1,b_2,\ldots,b_n)\in I^n$ satisfying $$E_k(a)< E_k(b) \hbox{for } k\in S\quad \hbox{and} \quad E_k(a)=E_k(b) \hbox{for } k\in \{0,1,\ldots,n{-}1 \}\setminus S\, .$$ As a corollary, we obtain \eqref{abstract_inequality} if $2\leq n\leq 4$, $f(x)=\log^2x$ and $S=\{1,\dotsc,n-1\}$, which is the sum of squared logarithms inequality previously known for $2\le n\le 3$.