With 2016 coming to a close, the S&P 500 is up 10.7% and is trading at a cyclically adjusted price-to-earnings ratio of 28 times. With that backdrop, it's getting progressively harder to find stocks selling at a bargain price that are actually worth your time as an investor. Most of the ones selling for cheap prices today are cheap for a reason: They make for awful long-term investments. 

That isn't the case with all inexpensive stocks, though. Two companies in particular -- Gilead Sciences (GILD 0.07%) and American Railcar Industries (NASDAQ: ARII) -- look to be two stocks with the traits you want in a long-term investment. To throw a cherry on top of it, both also pay attractive dividends. So let's take a quick look at why these companies are selling for decent discounts and why you may want to consider them for your own dividend portfolio.

Image source: Getty Images.

A biotech bargain

When you think dirt-cheap stocks, very rarely do healthcare or biotech companies find themselves in the discussion. Yet here's Gilead Sciences currently trading for a P/E ratio of just 6.8 times. Just about any company trading at that low of a multiple is typically priced for catastrophic failure, but that number alone doesn't even show how cheap this company is. 

Image source: Getty Images.

If you dig into the balance sheet, you'll find that Gilead Sciences is sitting on $31.6 billion in cash, short-term investments, and long-term marketable securities. Put another way, that's about $24 per share in straight up cash. If we were to back out this total amount of cash from the company's current market cap, that means that Gilead is trading at an even more absurd-sounding 4.6 times earnings. 

Granted, the company's current cash-cow treatments for both hepatitis C and HIV are starting to stall out as it faces greater competition and Gilead's offerings are starting to even cannibalize other treatments for the same disease. It's also worth noting that Gilead has announced a few duds in its research pipeline that are discouraging investors about the company's future earnings potential. However, not all treatments are expected to make it through to a commercial markets, and it still has about 30 treatments currently in its pipeline that could deliver either modest growth in its existing treatments or even start to tackle lucrative yet unexplored markets. 

Let's not forget about that cash pile, too. With $31 billion at its disposal, it has the ability to make a few acquisitions that could help bolster its portfolio. Based on the way this stock is priced today, it only has to generate modest success from both its current pipeline and through acquisitions to meet the markets expectations. 

A strong performer in an out-of-favor industry

American Railcar Industries is one of the companies that you could say was collateral damage from the decline in shale oil activity in the U.S. American Railcar manufactures two types of railcars: tanker cars used for liquid transport and hopper cars used for dry bulk products ranging from grains, sand, cement, plastic pellets, and specialty chemical products.

Image source: Getty Images

Based on these two offerings, it's pretty quick to see why Wall Street so closely ties this industry to the oil and gas business. From 2012 to 2014, oil via rail was a major component of moving crude oil from places like the Bakken shale basin in the Dakotas. Also, frack sand was gobbling up all the spare hopper cars available to deliver sand from the largest production places in Minnesota and Wisconsin to the prominent shale basins across the U.S.

It's also not too much of a surprise, then, that when oil prices started to plunge toward the end of 2014, the oil industry's demand for railcars dried up fast. Since 2014, American Railcar's backlog of railcars has declined 57% to 5,085 total cars, and operating margins have taken a hit as well. These elements have all led to the company's stock declining close to 40% over the past three years.

This year may be a tough one for American Railcar and other railcar manufacturers as the industry works through an oversupplied railcar market. One reason to be hopeful, though, is that the industry is cyclical. Another is that there is still quite a bit of room to grow for the hopper business. While drilling activity isn't as robust as it was, the amount of sand used per well has more than doubled in just about every shale basin in the U.S. This suggests that demand for hopper cars will pick back up even if drilling activity doesn't return to its 2014 highs. 

ARII Return on Equity (TTM) Chart

ARII return on equity (TTM) data by YCharts.

Today, even after lower earnings in 2016, American Railcar's stock trades at a modest 10.6 times earnings. Like Gilead Sciences, American Railcar also has a good amount of cash as well as short- and long-term investments on the books, about $11.50 per share. If we back out cash, American Railcar is trading at a very cheap 7.9 times earnings. For a company that has produced solid returns on equity, raised its dividend, and bought back stock over the past five years, that's a pretty good bargain.