The cup product in the cohomology of algebras over quadratic operads has been studied in the general setting of Koszul duality for operads. We study the cup product on the cohomology of n-ary totally associative algebras with an operation of even (homological) degree. This cup product endows the cohomology with the structure of an n-ary partially associative algebra with an operation of even or odd degree depending on the parity of n. In the cases n=3 and n=4, we provide an explicit definition of this cup product and prove its basic properties.