Let \(n\) be the integer such that \(0 \le n < 31\) and \(3n \equiv 1 \pmod{31}\) . What is \(\left(2^n\right)^3 - 2 \pmod{31}\)? Express your answer as an integer from 0 to 30, inclusive.
I used a calculator, and got an answer of 17.