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