# How to draw array with arrows?

I want to draw this:

Till now I am able to draw this much but struggling with red arrows

\documentclass{article}
\usepackage{etoolbox}
\begin{document}
\begin{center}
\begin{tabular}{ |c|c|c|c|c|c|c|c| }
\hline
3 & 4 & 2 & 1 & 4 & 1 & 2 & 3  \\
\hline
\hline
\end{tabular}
\end{center}
\end{document}


If you accept a pure TikZ solution:

\documentclass[tikz,border=2mm]{standalone}
\usetikzlibrary{positioning,matrix, arrows.meta}

\begin{document}
\begin{tikzpicture}
\matrix (A) [matrix of nodes, nodes={draw, minimum size=8mm},
column sep=-\pgflinewidth]{
3 & 4 & 2 & 1 & 4 & 1 & 2 & 3\\};
\foreach \i [evaluate=\i as \ni using {int(\i)},
evaluate=\i as \ntext using {int(\i-1)}] in {1,3,4,6}
\draw [{Stealth}-, red!70] (A-1-\ni.south west)--++(-90:5mm) node[below] {\ntext};
\end{tikzpicture}
\end{document}


• In beamer class it is giving error how to fix it for beamer class – new_born Nov 20 '17 at 15:39
• it works with beamer as expected: just replace first code line with \documentclass{beamer} \usepackage{tikz} – Zarko Nov 20 '17 at 15:43
• @new_born Works with beamer. Add [fragile] option to frame containing this matrix or add ampersand replacement=\& into matrix options and replace all & with \&. Next time, inform us that you want to use beamer: it's an important information. – Ignasi Nov 20 '17 at 16:05