[Tex/LaTex] How to add a logo to the upper-right or bottom-right of each page in beamer

beamer

Friends, I'd like to add a logo to the upper-right or bottom-right of each page in beamer. But I cannot figure it out. I can only add it to the footline. In this case, the title and name are omitted. How can I solve it?
Here is a minimal example of my Beamer TeX. Thanks a lot.

\documentclass[12pt]{beamer}
\mode<presentation> {
\usetheme{Madrid}
\setbeamertemplate{navigation symbols}{}
}
\usepackage{indentfirst,amsmath, multicol,amssymb}
\usepackage{caption}
\usepackage{booktabs,colortbl} 

\usepackage{grffile,threeparttable}
\usepackage{graphicx,subfig,graphbox} 
\usepackage{tikz}
\usepackage[absolute,overlay]{textpos}
\setbeamertemplate{caption,footline}[numbered]

\def\name{Yan}
\hypersetup{
    colorlinks = true,
    urlcolor = blue,
    pdfauthor = {\name},
}
    \title[Introduction ]{An Introduction} 
\author{
    Yan}
\institute[CU] 

\medskip

\date{\today} % Date


\begin{document}
    \tikzstyle{every picture}+=[remember picture]
    
    \everymath{\displaystyle}

    \begin{frame}
        \titlepage 
    \end{frame}
    
    \begin{frame}{Outline} 
        \tableofcontents 
    \end{frame}

   
\section{Background}
   
    \begin{frame}{Why}

a integrated 

\end{frame}

\end{document}

Best Answer

why don't you use the \logo macro. Simply put it in document's preamble.

\logo{\includegraphics{pic}}

it puts the content at the bottom-right of each page.