Whoever willfully violates, attempts to violate, or conspires to violate, any provision of this chapter or any regulation or order issued or any terms of a license granted thereunder shall, upon conviction thereof, be punished by a fine of not more than $5,000 or by imprisonment for not more than two years, or both, except that whoever commits such an offense with intent to injure the United States or with intent to secure an advantage to any foreign nation, shall upon conviction thereof, be punished by a fine of not more than $20,000 or by imprisonment for not more than twenty years, or both.