better way to calc. Go through array once.