#include <bits/stdc++.h>
using namespace std;
int n;
string s[100005][2];
long long in[100005];
long long dp[100005][2];
int main() {
  cin >> n;
  for (int i = 0; i < n; ++i) {
    cin >> in[i];
  }
  for (int i = 0; i < n; ++i) {
    cin >> s[i][0];
    s[i][1] = s[i][0];
    reverse(s[i][1].begin(), s[i][1].end());
  }
  for (int i = 0; i < n; ++i) {
    dp[i][0] = 9999999999999999;
    dp[i][1] = 9999999999999999;
  }
  dp[0][0] = 0;
  dp[0][1] = in[0];
  for (int i = 1; i < n; ++i) {
    if (dp[i - 1][0] != 9999999999999999) {
      if (s[i][0] >= s[i - 1][0]) {
        dp[i][0] = dp[i - 1][0];
      }
      if (s[i][1] >= s[i - 1][0]) {
        dp[i][1] = dp[i - 1][0] + in[i];
      }
    }
    if (dp[i - 1][1] != 9999999999999999) {
      if (s[i][0] >= s[i - 1][1]) {
        dp[i][0] = min(dp[i][0], dp[i - 1][1]);
      }
      if (s[i][1] >= s[i - 1][1]) {
        dp[i][1] = min(dp[i][1], dp[i - 1][1] + in[i]);
      }
    }
    if (dp[i][0] == 9999999999999999 && dp[i][1] == 9999999999999999) {
      cout << -1;
      return 0;
    }
  }
  cout << min(dp[n - 1][0], dp[n - 1][1]);
  return 0;
}
