Install games/apps on unlocked iphone 3gs

Hi everyone,
I am new to iphone and it's unlocked with ATT. I found some applications shared thru torrent. Some file's extention is .ipa or something like that.Iam wonder how can I install the files into iphone? Thanks for reply.