Let $n>1$, $X$ be a set of cardinality $n$ and $A_1,\ldots, A_k$ be a sequence of distinct subsets of $X$ such that $|A_i\cup A_j \cup A_l \cup A_f|<n-1$ for all $1\leq i, j, l, f\leq k$. Show that $k\leq 2^{n-2}$.
I tried many techniques to solve that problem, in particular I solved some simple cases, observed that the proof is straightforward if there exists an element which is in at least $2^{n-3}-1$ of sets $A_i$ or if there exist three of them such that their union has cardinality exactly $n-2$, but I don't know if this is helpful when considering the general case. Any help will be appreciated.