A school uses two different types of graphing calculators. Basic graphing calculators cost $80 each and CAS graphing calculators cost $100 each. The schoolneeds between 40 and 80 CAS graphing calculators for thier advanced math classes and at least 300 basic graphing calculators for all other math and science classes. The school earns $1 in rewards for each basic calculator and $2 in rewards for each CAS calculator and expect to earn at most $520 in rewards through this purchas. How many of each type should they purchase to minimize cost?