"vi doesn't have support for arrow keys. However, chances are you're actually using vim, which vi is often symlinked to for compatibility (I'm not certain what Ubuntu does, so I'm just guessing). Although vim supports the arrow keys, they tend to be disabled when run as vi.
If you are using vim, you can try typing the following command:
:set nocompatible
and see if that fixes the problem. This can also be loaded into your ~/.vimrc configuration file to load automatically every time you start the program.