A generalization of the parallelogram law to higher dimensions