#include <bits/stdc++.h>
using namespace std;
template <class T>
inline bool read(T &x) {
  int c = getchar();
  int sgn = 1;
  while (~c && c < '0' || c > '9') {
    if (c == '-') sgn = -1;
    c = getchar();
  }
  for (x = 0; ~c && '0' <= c && c <= '9'; c = getchar()) x = x * 10 + c - '0';
  x *= sgn;
  return ~c;
}
template <class T>
inline T bigmod(T p, T e, T M) {
  long long int ret = 1;
  for (; e > 0; e >>= 1) {
    if (e & 1) ret = (ret * p) % M;
    p = (p * p) % M;
  }
  return (T)ret;
}
template <class T>
inline T gcd(T a, T b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
template <class T>
inline T modinverse(T a, T M) {
  return bigmod(a, M - 2, M);
}
inline int Set(int N, int pos) { return N = N | (1 << pos); }
inline int Reset(int N, int pos) { return N = N & ~(1 << pos); }
inline bool check(int N, int pos) { return (bool)(N & (1 << pos)); }
int arr[100002][2];
string str[100002][2];
long long int dp[100002][2];
int n;
long long int solve(int ii, int jj) {
  if (ii >= n) return 0;
  if (dp[ii][jj] != -1) return dp[ii][jj];
  long long int ret1 = 1000000000000000;
  long long int ret2 = 1000000000000000;
  if (str[ii][jj] <= str[ii + 1][0]) {
    ret1 = solve(ii + 1, 0) + arr[ii + 1][0];
  }
  if (str[ii][jj] <= str[ii + 1][1]) {
    ret2 = solve(ii + 1, 1) + arr[ii + 1][1];
  }
  return dp[ii][jj] = min(ret1, ret2);
}
int main() {
  ios_base::sync_with_stdio(0);
  cin >> n;
  int i, j;
  for (i = 1; i < n + 1; i++) {
    arr[i][0] = 0;
    cin >> arr[i][1];
  }
  for (i = 1; i < n + 1; i++) {
    cin >> str[i][0];
    string temp, sc;
    temp = str[i][0];
    for (int j = temp.size() - 1; j >= 0; j--) {
      sc += temp[j];
    }
    str[i][1] = sc;
  }
  string temp;
  temp += 'a';
  str[0][0] = temp;
  memset(dp, -1, sizeof(dp));
  long long int ret = solve(0, 0);
  if (ret >= 1000000000000000)
    cout << "-1" << endl;
  else
    cout << ret << endl;
  return 0;
}
