#include <bits/stdc++.h>
using namespace std;
int c[100001];
long long dp[100001][2];
string str[100001][2];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int n, i, j, k;
  cin >> n;
  for (i = 1; i <= n; i++) cin >> c[i];
  for (i = 1; i <= n; i++) {
    cin >> str[i][0];
    str[i][1] = str[i][0];
    reverse(str[i][1].begin(), str[i][1].end());
    for (j = 0; j < 2; j++) {
      dp[i][j] = 1000000000000000000;
      for (k = 0; k < 2; k++) {
        if (str[i][j] >= str[i - 1][k])
          dp[i][j] = min(dp[i][j], dp[i - 1][k] + c[i] * j);
      }
    }
  }
  if (min(dp[n][0], dp[n][1]) == 1000000000000000000)
    cout << "-1";
  else
    cout << min(dp[n][0], dp[n][1]);
  return 0;
}
