#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<long long> cost(n);
  for (int i = 0; i < n; i++) {
    cin >> cost[i];
  }
  vector<string> str(n);
  vector<string> str2(n);
  for (int i = 0; i < n; i++) {
    cin >> str[i];
    str2[i] = str[i];
    reverse(str2[i].begin(), str2[i].end());
  }
  vector<vector<long long>> dp(2, vector<long long>(n, LLONG_MAX / 2));
  dp[0][0] = 0;
  dp[1][0] = cost[0];
  for (int i = 1; i < n; i++) {
    if (str[i] >= str[i - 1]) {
      dp[0][i] = min(dp[0][i], dp[0][i - 1]);
    }
    if (str[i] >= str2[i - 1]) {
      dp[0][i] = min(dp[0][i], dp[1][i - 1]);
    }
    if (str2[i] >= str[i - 1]) {
      dp[1][i] = min(dp[1][i], dp[0][i - 1] + cost[i]);
    }
    if (str2[i] >= str2[i - 1]) {
      dp[1][i] = min(dp[1][i], dp[1][i - 1] + cost[i]);
    }
    if (dp[0][i] == dp[1][i] && dp[1][i] == LLONG_MAX / 2) {
      cout << -1;
      return 0;
    }
  }
  cout << min(dp[0][n - 1], dp[1][n - 1]) << endl;
}
