With employing of TikZ libraries chains and positioning:
\documentclass[tikz, margin=3mm]{standalone}
\usetikzlibrary{chains, positioning}
\begin{document}
\begin{tikzpicture}[
node distance = 4mm,
start chain = A going right,
box/.style = {draw, minimum size=1.5cm,
label={[anchor=north,font=\large]:#1},
on chain=A}
]
\foreach \i in {I, II, III, IV, V}
\node[box=\i] {};
\draw ([xshift=-5mm] A-1.west) |- ([yshift=5mm] A-1.north) -| ([xshift=5mm] A-5.east);
\end{tikzpicture}
\end{document}

and with use of Stefan Kottwitz answer on for Roman numerals, which enable to draw arbitrary long chain of nodes:
\documentclass[tikz, margin=3mm]{standalone}
\usetikzlibrary{chains, positioning}
\makeatletter
\newcommand*{\rom}[1]{\expandafter\@slowromancap\romannumeral #1@}
\makeatother
\begin{document}
\begin{tikzpicture}[
node distance = 4mm,
start chain = A going right,
box/.style = {draw, minimum size=1.5cm,
label={[anchor=north,font=\large]:\rom{#1}}, % <---
on chain=A}
]
\def\Nmax{5} % <---
\foreach \i in {1,...,\Nmax} % <---
\node[box=\i] {};
\draw ([xshift=-5mm] A-1.west) |-
([yshift=5mm] A-1.north) -| ([xshift=5mm] A-\Nmax.east); % <---
\end{tikzpicture}
\end{document}
Result is the same as before.
I understand the foreach, but what is `\node and how do you get the |----| around it?
– LooselySubtle May 18 '19 at 19:36\nodeis a TikZ command that, well, defines a node. This node has a main argument, its content, which is often a text (but can also be a graphics etc.). And these nodes have anchors, which we are using when we draw the hat over them. TikZ has a lot of functions, but the good news is that the pgfmanual has a nice tutorial, and this site many examples from which one can learn. – May 18 '19 at 19:40