A quaternionic version of the Calabi problem was recently formulated by M. Verbitsky and the author. It conjectures a solvability of a quaternionic Monge-Ampere equation on a compact HKT manifold (HKT stays for HyperKaehler with Torsion). In this paper this problem is solved under an extra assumption that the manifold admits a flat hyperKaehler metric compactible with the underlying hypercomplex structure. The proof uses the continuity method and a priori estimates.