#include <bits/stdc++.h>
using namespace std;
long long int fast_expo(long long int x, long long int p) {
  if (p == 0)
    return 1;
  else if (p % 2 == 0) {
    long long int t = fast_expo(x, p / 2) % 1000000007;
    return (t * t) % 1000000007;
  } else
    return (x * (fast_expo(x, p - 1)) % 1000000007) % 1000000007;
}
long long int gcd(long long int a, long long int b) {
  if (a == 0 || b == 0)
    return a + b;
  else
    return gcd(b % a, a);
}
long long int dp[100001][2];
long long int cost[100001];
string Reverse(string str) {
  long long int n = str.size();
  for (long long int i = 0; i < n / 2; ++i) {
    char temp = str[i];
    str[i] = str[n - 1 - i];
    str[n - 1 - i] = temp;
  }
  return str;
}
long long int solve(long long int i, long long int j, string strarr[],
                    string rstrarr[]) {
  if (i < 0 || j < 0 || j > 1) return 922337203685477;
  if (dp[i][j] != -1) return dp[i][j];
  if (i == 0) {
    if (j == 0)
      return dp[i][j] = 0;
    else
      return dp[i][j] = cost[0];
  }
  if (j == 0) {
    long long int temp1 = 922337203685477, temp2 = 922337203685477;
    if (strarr[i] >= strarr[i - 1]) {
      temp1 = solve(i - 1, 0, strarr, rstrarr);
    }
    if (strarr[i] >= rstrarr[i - 1]) {
      temp2 = solve(i - 1, 1, strarr, rstrarr);
    }
    return dp[i][j] = min(temp1, temp2);
  } else {
    long long int temp1 = 922337203685477, temp2 = 922337203685477;
    if (rstrarr[i] >= strarr[i - 1]) {
      temp1 = solve(i - 1, 0, strarr, rstrarr);
    }
    if (rstrarr[i] >= rstrarr[i - 1]) {
      temp2 = solve(i - 1, 1, strarr, rstrarr);
    }
    return dp[i][j] = min(temp1, temp2) + cost[i];
  }
}
int main() {
  long long int n;
  cin >> n;
  for (long long int i = 0; i < n; ++i) cin >> cost[i];
  string strarr[n], rstrarr[n];
  for (long long int i = 0; i < n; ++i) {
    cin >> strarr[i];
    rstrarr[i] = Reverse(strarr[i]);
  }
  memset(dp, -1, sizeof(dp));
  long long int ans =
      min(solve(n - 1, 0, strarr, rstrarr), solve(n - 1, 1, strarr, rstrarr));
  if (ans >= 922337203685477) {
    cout << "-1";
  } else
    cout << ans;
  return 0;
}
