#include <bits/stdc++.h>
using namespace std;
const int maxN = 1e5 + 100;
long long int dp[maxN][2], val[maxN], n;
string s[maxN], t[maxN];
int main() {
  cin >> n;
  for (int i1 = 1; i1 <= n; i1++) {
    cin >> val[i1];
    dp[i1][0] = dp[i1][1] = 1e16;
  }
  for (int i = 1; i <= n; i++) {
    cin >> s[i];
    t[i] = s[i];
    for (int i2 = 0; i2 < s[i].size() / 2; i2++)
      swap(t[i][i2], t[i][s[i].size() - i2 - 1]);
    if (i == 1)
      dp[i][0] = 0, dp[i][1] = val[i];
    else {
      if (s[i] >= s[i - 1]) dp[i][0] = dp[i - 1][0];
      if (s[i] >= t[i - 1]) dp[i][0] = min(dp[i][0], dp[i - 1][1]);
      if (t[i] >= s[i - 1]) dp[i][1] = dp[i - 1][0] + val[i];
      if (t[i] >= t[i - 1]) dp[i][1] = min(dp[i][1], dp[i - 1][1] + val[i]);
    }
  }
  cout << (min(dp[n][0], dp[n][1]) < 1e16 ? min(dp[n][0], dp[n][1]) : -1)
       << endl;
  ;
}
