#include <bits/stdc++.h>
using namespace std;
const long long N = 1e5 + 9;
const long long OO = (long long)1e15 + 9;
const double EPS = 1e-6;
const long long mod = (long long)1e9 + 7;
void init() {}
bool isPrime(long long number) {
  for (long long i = 2; (long long)i * i <= number; i++) {
    if (number % i == 0) return false;
  }
  return true;
}
int cost[N];
string arr[N][2];
long long mem[N][2];
int n;
long long solve(int i = 0, bool rev = 0) {
  if (i == n) return 0;
  long long &ret = mem[i][rev];
  if (~ret) return ret;
  ret = OO;
  if (i == 0 || arr[i - 1][rev] <= arr[i][0]) ret = min(ret, solve(i + 1, 0));
  if (i == 0 || arr[i - 1][rev] <= arr[i][1])
    ret = min(ret, solve(i + 1, 1) + cost[i]);
  return ret;
}
int main() {
  memset(mem, -1, sizeof mem);
  cin >> n;
  for (size_t i = 0; i < n; i++) {
    cin >> cost[i];
  }
  for (size_t i = 0; i < n; i++) {
    cin >> arr[i][0];
    string temp = arr[i][0];
    reverse(temp.begin(), temp.end());
    arr[i][1] = temp;
  }
  long long ans = solve();
  if (ans == OO)
    cout << -1 << endl;
  else
    cout << solve() << endl;
}
